0

I am struggling to write an apple script and am looking for some help :)

The idea of the script is as follows:

  1. Ask user for INPUT and OUTPUT location
  2. Create 2 folders in OUTPUT location ("r3d" and "mov")
  3. Scan folders in INPUT location for ".R3D" files and copy to "OUTPUT>rd3"
  4. Scan folders in INPUT locations for ".mov" files and copy to "OUTPUT>mov"
  5. Prompt when process is complete.

My AppleScript skills are very basic this is the idea of the script I have but it is clear that this won't work. Would someone be able to help me out and tweak this?

display dialog "choose input"
set INPUT to choose file

display dialog "choose output"
set OUTPUT to choose file

tell application "Finder"
    make new folder at OUTPUT with properties{name:"mov"}
    make new folder at OUTPUT with properties{name:"r3d"}
end tell

tell application "Finder"
    move (every file of folder INPUT whose name extension is "mov") to folder "OUTPUT:mov"
    move (every file of folder INPUT whose name extension is "R3E") to folder "OUTPUT:r3d"
end tell

display dialog "Process Complete"
reveal OUTPUT

Would very much appreciate any sort of help. This piece of code might be useful for other people working with the RED camera system and wanting to streamline their file organisation process to split proxy and RED files.

Regards, Pierre

1 Answer 1

1

There are a few problems with your script:

  1. There is a choose folder command for choosing a folder (check out the AppleScript Language Guide for the various statements and commands);
  2. Trying to create a new folder where it already exists will result in an error, so you will need to either trap the error or look first to see if the folder already exists;
  3. The reveal command is for the Finder, so it needs to be in a Finder tell statement.
set INPUT to choose folder with prompt "Choose the input folder:"
set OUTPUT to choose folder with prompt "Choose an output folder:"

tell application "Finder"
   if not (exists folder "mov" of OUTPUT) then make new folder at OUTPUT with properties {name:"mov"}
   if not (exists folder "r3d" of OUTPUT) then make new folder at OUTPUT with properties {name:"r3d"}
   
   move (every file of folder INPUT whose name extension is "mov") to folder "mov" of OUTPUT
   move (every file of folder INPUT whose name extension is "R3E") to folder "r3d" of OUTPUT
   reveal OUTPUT
end tell

display dialog "Process Complete"

Note that if a file extension hasn’t been registered with the system (by an application that will recognize it), it won’t be considered by the Finder as an actual extension when using a filter reference form (the whose clause).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .