I want to make an Automator action that copies a set of files from a folder to another folder that is one folder up and then two folders down from the original files. In other words: ../Folder1/Folder2. The Automator action would be in the same folder as the files, but the root folder will be duplicated and renamed across multiple computers, so the path MUST be relative.
My understanding is that I need to run an Applescript to grab the current path and then do…something. I have zero scripting experience. Can anyone help?
Best Answer
Instead of AppleScript, you could do it by adding a Run Shell Script module with this content:
Edit the names of Folder1/Folder2 to match your actual case.
Choose As arguments from the Pass Input: pop-up at right where it says to stdin.
$@
stores the full path of all files selected.$F
is each individual file's path as it is processed by thefor
loop. The weird${F%/*/*}
is the full path of the file minus the file name and its parent folder name. The weird${F##*/}
is the file name itself.Test first for safety!
The other way to do it, which I think would be easier in the long run:
cd
space and drag the folder containing your files into the window. (This will paste in the path to that folder. Be sure to include the space aftercd
before you drag-and-drop.)cp *Video* ../Folder1/Folder2