folder action to auto-move large amounts of media based on names

Hey guys, sorry for this newb question.

I’m using compressor to batch out about 100 quicktimes/day for a TV show to image sequences in subfolders in a master folder. I then have to move each of those subfolders into a specific folder on a server for each one.

For example - I write out “101_27-10_FGPLATE.mov” to the folder “DROPBOX/101_27-10_FGPLATE” within that folder there will be about 100 DPX files named “101_27-10_FGPLATE.0001.dpx” and so on.

Once I batch out all my quicktimes, I need to move all the folders to //SERVERPATH/101/101_27-10/2D/FOOTAGE/"

So I want to make a script that goes:

Take the first three digits of the folder name (“101”) and store it as a variable EPISODE_NUMBER
Take the first 9 digits of the folder name (“101_27-10”) and store it as the variable SHOT_NUMBER
Once all compressor is done putting all of the dpx files into the folder, move the folder and its entire contents to:
“//SERVERPATH/EPISODE_NUMBER/SHOT_NUMBER/2D/FOOTAGE”

Is there anyway someone could find it in their heart to help me with this? I am ok with actionscript/javascript/after effects expressions. But apple script is new to me.

One immediate thought is, how will assigning a script to a folder action know to wait for all the images to be in a folder, if the number of images will vary on each shot? If it can’t be a folder action, it can just be a script that I run after each batch. or, now that I think about it, compressor has the ability to run a script as a post render action, so that might just be the best way!

Any help much appreciated!

Stephan Fleet
Knight Rider

Hi Stephan,

welcome to MacScripter.

It seems not too difficult to develop a solution for your request, but personally I have a peculiar feeling to help free of charge for an obvious high level commercial purpose.
What’s about the idea to give a freelancer a chance to earn a little fraction of the money you save with the script. :wink:

were this to be something my bosses commissioned, I would gladly pay. My goal is to learn how to do this myself, exactly because no one at my gig will commission this. I don’t have the authority or the money of my own to hire a contractor. Fact is, since no one responded I asked our IT if he could do something in Perl or Python (since he is unfamiliar with macs). So sadly, I will probably not get an applescript solution out of here, and not learn how to do something like this myself - which is my real goal.

I’m sorry, this is and was no personal offense.

I just wrote my own opinion, probably you get a solution from somebody else.

I’m pretty sure, that a TV station can afford some bucks for a better workflow which saves much more time and money as the fee for the script.

Programming (including scripting) is a serious profession like making TV productions.
I think, your bosses won’t ever give away their products for commercial use for free :wink:

If you want to learn how to do it yourself, this may get you started:

tell application "Finder"
	set myFolder to (choose folder) as alias
	set EPISODE_NUMBER to text 1 thru 3 of (name of myFolder as text)
	set SHOT_NUMBER to text 1 thru 9 of (name of myFolder as text)
	set mydestination to (choose folder) as alias
	move myFolder to mydestination
end tell

It would be best to run it post render action as you say.

You don’t say what you need done with the episode number and shot number variables, but this shows you how to define them. You might want to predefine the source and/or destination folders somehow. Perhaps the script can get them from compressor?

sweet! Thanks that helped a LOT, I already figured out how to get the code to read like this:


tell application "Finder"
	set myFolder to (choose folder) as alias
	set EPISODE_NUMBER to text 1 thru 3 of (name of myFolder as text)
	set SHOT_NUMBER to text 1 thru 10 of (name of myFolder as text)
	set mydestination to ("mkkr:ARTISTS:Stephan:Testing:" & EPISODE_NUMBER & ":" & SHOT_NUMBER & ":2D:00_footage") as alias
	move myFolder to mydestination
end tell

Which works fantastically.

Now, my last question - how do I tell applescript to do this upon completing a compressor action instead of having it pop up to select the folder. I know how to assign a post render applescript to compressor. The question is, what is the code for “Set my Folder TO THE FOLDER THAT COMPRESSOR JUST RENDERED OUT”

Thanks so much for your help, this is awesome!

I don’t have Compressor, so I can’t help you with it, but if you get Compressor to open the folder in the Finder, you could use:

set myFolder to (folder of the front window) as alias

What are you using the EPISODE_NUMBER and SHOT_NUMBER variables for?

I’m using those variables to establish the folder path, which uses elements of the origin folder name. I have that working great. It’s just this out of compressor thing I am working on!

on a side note, what if I wanted to select a file instead of a folder, is the syntax the same?

Oops! I see above. Must pay more attention.

Yes, an alias is an alias.