One thing I noticed setting up PHP and MySQL on Leopard, is that the default PHP build looks for the MySQL socket in /var/mysql/mysql.sock which doesn’t exist and isn’t the location that MySQL would use if it did (by default anyway). By default the MySQL socket is: /tmp/mysql.sock.
There are four ways to fix this:
- Create the /var/mysql directory (
sudo mkdir /var/mysql) and then create a symbolic link from /tmp/mysql.sock to /var/mysql/mysql.sock (with: sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock).
- Edit the
/etc/php.ini file (it may not exist in which case just sudo cp /etc/php.ini.default /etc/php.ini) so that the mysql.default_socket = /tmp/mysql.sock (by default line 760) and mysqli.default_socket = /tmp/mysql.sock (by default line 795).
- Edit
/etc/my.cnf adding the following lines:
[mysqld]
socket=/var/mysql/mysql.sock
[client]
socket=/var/mysql/mysql.sock
This will tell MySQL to create its socket where Leopard’s default PHP is looking for it. Next, you also need to create the /var/mysql directory and sudo chown mysql /var/mysql it or MySQL won’t start since it wont be able to create the socket.
- Recompile php for your version of MySQL (a PIA, but not a terrible idea at all).
Of these #1 is easiest, but a bit of a hack. #2 is the easiest real way. #3 isn’t to bad, but could cause issues with other MySQL clients that look for the socket in /tmp/mysql.sock. #4 is ultimately the best fix, but is clearly neither very fast nor particularly easy
For years I’ve been using the excellent ExifRenamer to rename my digital photos when I imported them by setting it up as the Automatic Task in OS X’s Image Capture application. When Aperture came out I tried using its built in renaming feature, but found it to be inflexible (and while subsequent updates have improved this feature, the “Time” value still adds unnecessary, unwanted “-”’s). Rather then start a whole new naming scheme after years and years I continued to use ExifRenamer with the Image Capture application.
Note: Until recently I never really used iPhoto. Prior to Aperture I would use iView Media Pro, which has subsequently been gobbled up by Microsoft and is now known as Expression Media , to manage all my photos. So the extra step involved using Image Capture rather then importing directly into Aperture never bothered me that much.
The thing is ExifRenamer hasn’t been updated since 2002, so I’ve been looking for a way to duplicate this function without added steps in my workflow. Other then ExifRenamer, I’ve found that most GUI based utilities tend to do more then I’d like, the thing about ExifRenamer is it did one thing very easily and extremely well, everything else I’ve found suffers from feature creep (though if you want to rename you images to something other then just EXIF timestamps, then A Better Finder Rename is definitely worth a look). Anyway after much searching, I realized that the answer was already right under my nose: ExifTool by Phil Harvey.
ExifTool is a Perl Module (Image::ExifTool) which comes complete with a command line tool (exiftool) that can do almost anything you want done with EXIF data. I had to use this once a while ago when I realized that the new (at the time) editing tools in iView Media Pro were overwriting the original EXIF dates (which nothing should ever do, no matter what the developer says) and I needed to change them back and this tools fit the bill. Turns out, that this tool is perfect for renaming files based on EXIF data too (in fact it can rename files, and move them in directories based on *any* EXIF data).
For my purposes, the exact exiftool command I want to run on each image is:
exiftool ‘-filename<CreateDate’ -d %Y%m%d_%H%M%S%%+c.%%e $x
In this command, ‘-filename<CreateDate’ actually does the renaming (passing the CreateDate to the filename). -d %Y%m%d_%H%M%S%%+c.%%e defines the format of CreateDate using strftime (see man strftime for info). (The %%+c.%%e (which add a file counter and the proper file extension) however are part of exiftool, not strftime (which is why they get two %’s, if you just used one % then you would use strftime‘s %c and %e which is not what we want).) $x is a variable which represents the original image file.
To be able to execute this command from Image Capture, I need to wrap this command inside of an Automator Application. So I open Automator and create a new workflow. My first action is simply “Get Selected Items” which will take the Finder items passed to the workflow and pass it to the next action. My second (and last) action is “Run Shell Script.”
For the Run Shell Script action set the Shell: to /bin/bash and Pass input: “as arguments.” Then in the script area input the following script:
for x in "$@"
do
exiftool '-filename<CreateDate' -d %Y%m%d_%H%M%S%%+c.%%e $x
done
Now save your Automator workflow as an Application and use it in Image Capture or on it’s own (By dragging images on it to use).
And That’s it.