Moving & renaming videos/fotos including AAE files

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

Moderator: Mr_Noodle

Since getting my iPhone 6 and upgrading to Yosemite my photos and videos include AAE files (Slow Motion Sidecar Files) which contain any non destructive filter information for images or the slow motion data for slo-mo videos.
This is now messing with my Hazel rules which don't grab these files.
For example I might have following files:
IMG_2543.JPG
IMG_2543.AAE

IMG_2544.JPG
IMG_2545.JPG
IMG_2546.MOV
IMG_2546.AAE

etc.

Currently my rules are quite simple (sticking with images for simplicity):

Kind is Image
Sort into subfolder - Pictures [date_created=Year]>[date_created=YYYY-MM-DD]
Rename - [date_created=YYYY-MM-DD]_[###].[extension]
I end up with
/Pictures 2014/2014-12-24/2014-12-24_001.jpg
/Pictures 2014/2014-12-24/2014-12-24_002.jpg
/Pictures 2014/2014-12-24/2014-12-24_003.jpg
/Pictures 2014/2014-12-24/2014-12-24_004.jpg
etc.

What I would like to do is grab the corresponding AAE files and rename them to the same name the image or video has been renamed to. Not sure if this is possible.

I would like to end up with:
/Pictures 2014/2014-12-24/2014-12-24_001.jpg
/Pictures 2014/2014-12-24/2014-12-24_001.aae

/Pictures 2014/2014-12-24/2014-12-24_002.jpg
/Pictures 2014/2014-12-24/2014-12-24_003.jpg
/Pictures 2014/2014-12-24/2014-12-24_003.aae

/Pictures 2014/2014-12-24/2014-12-24_004.jpg

Can this be achieved with Hazel?
Thanks.
andy_vdg
 
Posts: 5
Joined: Sat Dec 27, 2014 6:45 pm

Do the files have the same date created? If so, why not just extend the rule you have to include AAE files as well?
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

There are two problems I'm faced with:
1. The AAE files can be related to jpg or mov file and I have two seperate rules for each kind of file. If I include aae files in both rules the first one will grab them all even if they are ment for the other filetype.
2. Once renamed they have to have the same exact filename as the corresponding jpg or mov file. The numerator breaks this link as it does not keep the names the same.

So basically I am looking for a way to match files based on the name with different extension and renaming them both to the same name.
The closest similar example would be shooting jpg and raw images and wanting to rename them both to the same name but with the added complexity of also having two video files as well.
Is this possible?
andy_vdg
 
Posts: 5
Joined: Sat Dec 27, 2014 6:45 pm

I think you may need to do a script for this type of logic then. Can't think of a good way, using the built-in functions, especially since you are trying to use the name of one file, post-rename, on another file.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Same problem here. Totally mucked up my workflow.
Wish there was a solution for this.
Since my workflow separates photo & video files, I've had to choose to abandon the sidecar for one of the two. Since I personally use third-party apps for photo editing & retouching, I've decided to ignore the photo sidecars. So, currently, my workflow...

1. Moves photos into subfolders (subfolders named by date, i.e., YYYY-MM) within a "Photos (Master Archive)" directory.

2. Moves videos and sidecar files into subfolders (again, subfolders named by date, i.e., YYYY-MM) within a "Videos (Master Archive)" directory.

Problem is, I end up with "orphan" sidecar files in my videos archives (i.e., sidecar files that actually belong to photos), but right now, that's the best solution I've come up with.

It's also resulted in the scrapping of any file-renaming since the media file (photo/video) and associated sidecar need
to have the same name.

Total bugger that's completely messed up my workflow.

Anyone else have a better idea?
kristin
 
Posts: 23
Joined: Tue Apr 10, 2012 12:34 pm

Just as a follow up—it was kinda driving me nuts that I was just tossing away sidecar files, as per my above post, so I've written the following AppleScript (below) which, which I first run on the files, before Hazel touches them. Basically, it does the following:

STEP 1: Sorts all PHOTO files (and associated SIDECAR files, if applicable) into a PHOTOS folder.
STEP 2: Sorts all VIDEO files (and associated SIDECAR files, if applicable) into a VIDEOS folder.
STEP 3: Sorts all OTHER files (not captured by steps 1 or 2) into an OTHERS folder.

I then have Hazel rules attached to the individual PHOTOS and VIDEOS folder, at which point it then continues with my Hazel-based workflows. I manually deal with the files in the OTHERS folder (this is just a safety net, incase there's a random photo extension I've missed, etc.).

This still isn't perfect—it doesn't solve the renaming issue, and there are issues with Hazel sorting the media files and sidecar files into subfolders based on creation date (as you could create the sidecar on a different date than the photo/video was taken, etc.), but at least, with running this script first, I'm not throwing anything away.

Below is the AppleScript to do the sorting. You can't use it as a Folder Action, but you can use it (via Automator) to create an Image Capture plugin (which you can then use when importing from your iPhone) or a stand-alone Application (droplet). Figure I'd post it here for anyone else who's run into this issue...

Thanks,
Kristin.

Code: Select all
on run {input, parameters}
   
   -- SET FILE EXTENSIONS
   
   -- PHOTO file extensions:
   set photoExtensionList to {"jpg","png","gif","raw","tif"}
   
   -- VIDEO file extensions:
   set videoExtensionList to {"mov","m4v"}
   
   -- SIDECAR file extensions:
   set sidecarExtensionList to {"aae"}
   
   
   -- SET FOLDER LOCATIONS
   
   -- move PHOTO (and SIDECAR, if available) files to this folder:
   set photoDestinationFolder to alias "LOCATION:WHERE:YOU:WANT:PHOTO:FILES:MOVED:TO"
   
   -- move VIDEO (and SIDECAR, if available) files to this folder:
   set videoDestinationFolder to alias "LOCATION:WHERE:YOU:WANT:VIDEO:FILES:MOVED:TO"
   
   -- move all OTHER files to this folder:
   set otherDestinationFolder to alias "LOCATION:WHERE:YOU:WANT:ALL:OTHER:FILES:MOVED:TO"
   
   tell application "Finder"
      set thePhotoMoveList to {}
      set theVideoMoveList to {}
      set theOtherMoveList to {}
      set photoMoveList to a reference to thePhotoMoveList
      set videoMoveList to a reference to theVideoMoveList
      set otherMoveList to a reference to theOtherMoveList
      
      -- populate lists of files to move
      repeat with the_item in input
         set the_item to (the_item as alias)
         if name extension of the_item is in photoExtensionList then
            copy the_item to the end of photoMoveList
            set parent_folder to (container of the_item) as alias as text
            set item_name to text 1 thru ((length of (the_item's name as text)) - (length of (the_item's name extension as text))) of (the_item's name as text)
            repeat with ext in sidecarExtensionList
               try
                  copy ((parent_folder & item_name & ext) as alias) to the end of photoMoveList
               end try
            end repeat
         else if name extension of the_item is in videoExtensionList then
            copy the_item to the end of videoMoveList
            set parent_folder to (container of the_item) as alias as text
            set item_name to text 1 thru ((length of (the_item's name as text)) - (length of (the_item's name extension as text))) of (the_item's name as text)
            repeat with ext in sidecarExtensionList
               try
                  copy ((parent_folder & item_name & ext) as alias) to the end of videoMoveList
               end try
            end repeat
         else if (name extension of the_item is not in videoExtensionList) and (name extension of the_item is not in sidecarExtensionList) and (name extension of the_item is not in sidecarExtensionList) then
            copy the_item to the end of otherMoveList
            set parent_folder to (container of the_item) as alias as text
            set item_name to text 1 thru ((length of (the_item's name as text)) - (length of (the_item's name extension as text))) of (the_item's name as text)
         end if
      end repeat
      
      -- MOVE FILES
      
      -- move PHOTO (and SIDECAR, if available) files
      move thePhotoMoveList to photoDestinationFolder without replacing
      
      -- move VIDEO (and SIDECAR, if available) files
      move theVideoMoveList to videoDestinationFolder without replacing
      
      -- move all OTHER files
      move theOtherMoveList to otherDestinationFolder without replacing
      
   end tell
end run
kristin
 
Posts: 23
Joined: Tue Apr 10, 2012 12:34 pm

Took a bit more time to look around and found this thread: http://update.noodlesoft.com/forums/viewtopic.php?f=4&t=1945#p8115

I changed the original:
Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     extension is mp4
     name matches MAH(123)

Do the following to the matched file or folder:
     rename with pattern (name);(date modified)(extension)
     run shell script (embedded script)


Code: Select all
NAME=$(echo "$(basename "$1")" | awk -F '[;.]' '{print $1}')
MOD_DATE_FORMATTED=$(echo "$(basename "$1")" | awk -F '[;.]' '{print $2}')

mv "$(dirname "$1")/$NAME.thm" "$(dirname "$1")/$MOD_DATE_FORMATTED.thm"

mv "$1" "$(dirname "$1")/$MOD_DATE_FORMATTED.mp4"




to:

Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     extension is jpg

Do the following to the matched file or folder:
     rename with pattern (name);(date created)_(#)(extension)
     run shell script (embedded script)
Be sure to set (name); in the rename pattern as this is what the script is looking for.

Code: Select all
NAME=$(echo "$(basename "$1")" | awk -F '[;.]' '{print $1}')
DATE_FORMATTED=$(echo "$(basename "$1")" | awk -F '[;.]' '{print $2}')

mv "$(dirname "$1")/$NAME.AAE" "$(dirname "$1")/$DATE_FORMATTED.aae"

mv "$1" "$(dirname "$1")/$DATE_FORMATTED.jpg"

In the first instance this works fine - it does in fact rename both the jpg and the .aae.
However it does not sort into subfolders and the numerator is not correct - it just continues numerating from the last known number in the folder Hazel watches - whereas I want it to put it into a subfolder YYYY-MM-DD and then numerate in that subfolder.
Maybe someone with more scripting skills than myself can give me a few pointers?
andy_vdg
 
Posts: 5
Joined: Sat Dec 27, 2014 6:45 pm

andy,

I've created a rule that should do what you want.

Here is an example of what it does.
I've tagged the example files with different colors so you can see that they are moved and renamed properly. Red is JPG/AAE. Green is JPG only. Blue is MOV/AAE.

Before:
Image
After: Hazel did all of this in a single "Run Rules Now". :)
Image

You can download the ruleset file from here. The ruleset should be simple enough to follow or modify and the shell scripts are fully commented.

To add it to Hazel, Open Hazel, select the monitored folder on the left, click the gear icon at the bottom, choose Import Rules and load my ruleset.

If you have any questions or problems, feel free to ask.

Hope this helps
Smudge
 
Posts: 34
Joined: Mon Jul 15, 2013 10:44 pm

You sir are my hero ;-)
Works perfectly - thanks a ton!
andy_vdg
 
Posts: 5
Joined: Sat Dec 27, 2014 6:45 pm

Hey all—still haven't been able to resolve the issue of having the media file (JPG, MOV, etc.) and the sidecar (AAE) file sometimes ending up in different subfolders when Hazel sorts by creation date (as sometimes the sidecar is created at a later date). Does anyone know a way (script?) that would find two files with the same name (different extensions) and then modify the creation date of one of those files?
kristin
 
Posts: 23
Joined: Tue Apr 10, 2012 12:34 pm

Can Hazel 4 handle this without writing a script? If so, is there a sample rule?
linghao
 
Posts: 1
Joined: Wed May 24, 2017 8:45 pm

A script is still needed.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support