Refining my photo management process

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Refining my photo management process Mon Jan 25, 2016 1:01 pm • by brudderman
I'm a new Hazel user here and am probably missing something obvious in getting to the result I want. First a little background for context.

By searching the forums here and the ExifTool forum I now have Hazel renaming my photo files as I desire with this ExifTool command, and it seems to work well when I manually copy files from my Camera Uploads directory into the proper destination directories (organized by Person/Event/Activity) in my main digital photos directory:
Code: Select all
exiftool -P -d '%Y-%m-%d '  '-filename<${directory;s(.*/)()} ${FileModifyDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${GPSDateTime;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${MediaCreateDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${ModifyDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${DateTimeOriginal;}  %.3c.%le' "$1"


In addition to renaming the files, I'd also like to copy each file's parent directory name into the file's Description tag so that I can sort on the Description in the Photos app. I can do this manually by running this ExifTool command (with the proper file path added) from Terminal:
Code: Select all
'-imagedescription<${directory;s(.*/)()}'


When I do this, however, ExifTool makes a backup of copy of the original file which must be deleted, but that's no issue in itself. But when I try to combine the addition of the description with the renaming, I run into the problem:
Code: Select all
exiftool -P '-imagedescription<${directory;s(.*/)()}' -d '%Y-%m-%d ' '-filename<${directory;s(.*/)()} ${FileModifyDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${GPSDateTime;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${MediaCreateDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${ModifyDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${DateTimeOriginal;}  %.3c.%le' "$1"


The process actually works, but since the writing of the directory name into the Description creates a backup file, that appears to cause Hazel to activate the folder rules again, creating an endless loop with multiple copies of the file being spawned.

I've tried the ExifTool -overwrite_original switch, but it doesn't actually suppress the creation of the backup file and doesn't stop the loop when added to my renaming code. I've also tried separating the renaming and description addition into two sequential shell scripts in the same Haze rule, but that doesn't help either.

I'd sure appreciate some pointers in how to get the renaming and the adding of the description to play well together. Surely my failure to do so is due to a lack of understanding of both Hazel and ExifTool, but hopefully I've given enough information here for someone with more knowledge to nudge me in the right direction. Just what I've done so far will greatly reduce my manual efforts, but adding this one tweak would sure be nice. Then I can move on to videos--with probably more questions here. :D

Thanks!!
brudderman
 
Posts: 8
Joined: Tue Jan 19, 2016 5:02 pm

Re: Refining my photo management process Mon Jan 25, 2016 5:32 pm • by Mr_Noodle
Instead of having your script do the renaming, if you convert it to an AppleScript, you can have it export the EXIF date to Hazel, where it can do the renaming itself. Otherwise, I think you'll have to figure out how to get exiftool to not produce the extra file, or add some extra scripting to remove it. Both of those solutions are outside of Hazel though.
Mr_Noodle
Site Admin
 
Posts: 11875
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Refining my photo management process Mon Jan 25, 2016 9:18 pm • by brudderman
Thanks for getting back with me so quickly, Mr. Noodle! I think I have the solution which will allow me to do it all in Hazel. Rather than incorporating the command to write the directory name into the description within the renaming command as I had posted earlier, I'm now running two separate ExifTool commands sequentially in the same shell script. First the renaming, and then writing the description:

Code: Select all
exiftool -P -d '%Y-%m-%d '  '-filename<${directory;s(.*/)()} ${FileModifyDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${GPSDateTime;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${MediaCreateDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${ModifyDate;}  %.3c.%le'  '-filename<${directory;s(.*/)()} ${DateTimeOriginal;}  %.3c.%le' "$1"; exiftool -P '-imagedescription<${directory;s(.*/)()}' "$1"


This still produces the backup files, but they don't create a loop, and I have Hazel delete them as a final step. So all appears well, but I need to do a little more testing just to make sure.

Next come the video files, and I'll probably be back with more questions! :D
brudderman
 
Posts: 8
Joined: Tue Jan 19, 2016 5:02 pm


Return to Support