Benches macOS

4

Run Automator when new file is added

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

I would like to move a file to a folder hierarchy based on file extension every time a file is downloaded to the downloads folder. I have created some Automator scripts to do this, but I think there might be a better way?

I posted this thread
http://discussions.apple.com/thread.jspa?threadID=2455708&tstart=0 and they recommended me to come here. Any thoughts?

4 replies

Sign in or join Beachball Help to reply.

  1. 0

    Pierre L.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Here's a very simple example of what can be done with AppleScript:

    *on adding folder items to this_folder after receiving added_items*

    try

    *tell application "Finder"*

    *set myDesktop to path to desktop folder as text*

    *repeat with thisFile in added_items*

    *set X to name extension of thisFile*

    *if X is "rtf" then*

    *move thisFile to folder (myDesktop & "A")*

    *else if X is "webloc" then*

    *move thisFile to folder (myDesktop & "B")*

    else

    *move thisFile to folder (myDesktop & "C")*

    *end if*

    *end repeat*

    *end tell*

    *end try*

    *end adding folder items to*

    If you attach the above script to your Downloads folder and create three new folders on your desktop, respectively named "A", "B" and "C", then any file added to your Downloads folder should be moved to one of these three folders, depending on its file extension.

    In order to attach the script to your Downloads folder, just save it to the “Folder Action Scripts” folder (/Library/Scripts/Folder Action Scripts); then double click the “Configure Folder Actions”
    alias located in the “Folder Actions” folder (/Library/Scripts/Folder Actions).

    Hope it can help.

  2. 0

    Pierre L.

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Here's a very simple example of what can be done with AppleScript:

    *on adding folder items to this_folder after receiving added_items*

    try

    *tell application "Finder"*

    *set myDesktop to path to desktop folder as text*

    *repeat with thisFile in added_items*

    *set X to name extension of thisFile*

    *if X is "rtf" then*

    *move thisFile to folder (myDesktop & "A")*

    *else if X is "webloc" then*

    *move thisFile to folder (myDesktop & "B")*

    else

    *move thisFile to folder (myDesktop & "C")*

    *end if*

    *end repeat*

    *end tell*

    *end try*

    *end adding folder items to*

    If you attach the above script to your Downloads folder and create three new folders on your desktop, respectively named "A", "B" and "C", then any file added to your Downloads folder should be moved to one of these three folders, depending on its file extension.

    In order to attach the script to your Downloads folder, just save it to the “Folder Action Scripts” folder (/Library/Scripts/Folder Action Scripts); then double click the “Configure Folder Actions”
    alias located in the “Folder Actions” folder (/Library/Scripts/Folder Actions).

    Hope it can help.

  3. 0

    red_menace

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    You can create your workflow as a folder action - the workflow will be triggered when items are added to the attached folder. The added items are automatically passed to your workflow, so additional actions to get the items aren't needed.

  4. 0

    nZac

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks, red_menace. I guess I had done that, but it wasn't working, I deleted and recreated them and now they work. Thanks!