-1

I need an Automator Folder Action workflow that when files are dropped into the folder the workflow is assigned to, it will first make a copy of the dropped files to one different folder, and then move the original dropped files to another different folder.

For example, say I want to drop a single file into a "Hot Folder", then have that file first copied to a different folder, and then the same file that was first copied, moved to another different folder.

This would leave the folder the file was originally dropped into empty while now having the originally dropped file in two different location by the Automator Folder Action workflow, one by copying it and the other by moving the file the copy was made from.

Can someone show me how to do this with Automator?

  • 1
    What have you got so far (even if it only moves the file to one location)? – nohillside Dec 14 '18 at 19:13
  • 1
    You can't move a file to two different folders. You would copy the file to two different folders or copy the file to one folder then move the file to the other folder. – fd0 Dec 14 '18 at 19:24
  • @fd0 I'm quite sure that copying to two folders and deleting the source is exactly what the OP wants :-) – nohillside Dec 14 '18 at 21:02
  • I tried the copy then move option, but I could only get the first copy to run. It seems like the script stops after the copy and will not complete the final move. I am using Folder Actions in Automator. – Gawly Dec 14 '18 at 21:31
  • If you have something already, please add it. You will benefit more from an improved version of your own script than from one somebody else wrote – nohillside Dec 15 '18 at 6:58
1

This following example Automator Folder Action workflow works for me.

This was tested with one file and many files at a time over a half dozen tests with different file counts and sizes, however I'd caution that this simple workflow might choke if invoked with to many really large files at one time.

Setup the workflow according to the individual actions in the order shown in the image further below and the Options shown on the two Get Value of Variable actions. Which are in order:

  • Start with setting the target folder for: Folder Action receives files and folders added to
  • Add a Set Value of Variable action, giving the Variable: a pertinent name.
  • Add a Get Value of Variable action, while setting the value of the Variable: list box to the value of Variable: set in the Set Value of Variable action, and check the [√] Ignore this actions input check box under its Options.
  • Add a Copy Finder Items action, while setting the To: list box to a pertinent target folder.
  • Add a Get Value of Variable action, while setting the value of the Variable: list box to the value of Variable: set in the Set Value of Variable action, and check the [√] Ignore this actions input check box under its Options.
  • Add a Move Finders Items action, while setting the To: list box to the a pertinent target folder.

enter image description here

Note: This workflow choice was made to show how to accomplish the task without the use of shell scripting and a Run Shell Script action, as some users may not be comfortable using shell scripting.


If you are comfortable using shell scripting, then this example Automator Folder Action workflow works for me too.

Setup the workflow according to the individual action shown in the image further below:

  • Start with setting the target folder for: Folder Action receives files and folders added to
  • Add a Run Shell Script action, while changing Pass input: from to stdin to as arguments. Then replace the original code with the following example code, while modifying the value of the copy and movefvariables to contain the POSIX pathname of the target folders the file is to be copied to first, and subsequently moved to from the "Hot Folder" it was dropped into.

    copyf="/Path/To/Copy To Folder"
    movef="/Path/To/Move To Folder"
    
    for f in "$@"; do
        cp -a "$f" "$copyf"
        mv "$f" "movef"
    done
    

enter image description here

  • To whomever down-voted this answer, please provide a legitimate reason for it as this is a working Automator Folder Action workflow for me in my testing and ultimately does what the OP asked for. If it doesn't work for you then you should comment on it that it didn't, so I can then help fix what may be wrong on your system. – user3439894 Dec 15 '18 at 3:56
  • Wouldn‘t it be easier to just use a shell script action? – nohillside Dec 15 '18 at 6:58
  • 1
    Thanks for the help. I did get the Automator workflow to work, but it appears that the files remain in the Hot Folder after they are sent to the output folders. Is there a way to actually MOVE the folder in the last step? It appears that is is being copied and not moved in the last step. – Gawly Dec 18 '18 at 17:14
  • 1
    Also, tried my hand at shell scripting, but what a wrote did not appear to work either. The files were not copied/moved to the paths I included. However, the source file was removed from the Hot Folder, so it was being moved somewhere, just not to the paths I entered as variables. – Gawly Dec 18 '18 at 17:48
  • copyf="smb://traco-hpindigo/hot_folders/PSLABEL1-CMYK/" movef="smb://traco-hpindigo2/hot_folders/PSLABEL2-CMYK/". for f in "$@"; do cp -a "$f" "$copyf" mv "$f" "movef" done – Gawly Dec 18 '18 at 17:53

You must log in to answer this question.

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