Folder Action Scripting Help

Posted:
in Genius Bar edited January 2014
With the advent of 10.3 and Folder Scripting, I was wondering if I could use these to my advantage.



I have a general downloads folder, and would it be possible to use Folder Actions to say, sort .dmgs to a specific folder? And .jpgs likewise?



One problem is that I have no Applescript experience - if anyone can tell me/write me () a generic Applescript to do this, I'll be dead chuffed come 24th Oct!

Comments

  • Reply 1 of 1
    This should be easy. OS X already supplies you with example folder action scripts. Look for a folder called Folder Action Scripts. The closest to your idea is one titled



    add - new item alert.scpt



    This script is triggered when you add new items to a folder. It then reveals them in the finder.



    What you want to do is duplicate this script and change the reveal part to code that moves different files to different folders based on the extension.



    Something like this. I haven't tried it but it should give you a start.



    \tset jpg_folder to ( define folder path here )

    \tset dmg_folder to ( define folder path here )

    \ttell application "Finder"

    \t\trepeat with i from 1 to item_count

    \t\t\tset fname to name of item 1 of added_items

    \t\t\tif fname ends with ".jpg" then move item 1 to jpg_folder

    \t\t\tif fname ends with ".dmg" then move item 1 to dmg_folder

    \t\tend repeat

    \tend tell
Sign In or Register to comment.