So simple a child could likely code this
January 15, 2010 2:23 PM   Subscribe

Using Automator and/or AppleScript to automatically move files of a specified type(s) from one folder to another?

This is likely a basic Automator/AppleScript question, but my Google-fu is failing me, I have yet to use Automator for anything worthwhile, and I haven't asked a question here in a few weeks, so revel in my ignorance!

I would like a workflow that moves all .jpg and .gif files (and ONLY those file types) from my Downloads folder to a folder labeled "Downloaded Images." Ideally, this job should run either automatically as a folder action or periodically as a cron job. In my mind, the way I'd like it to run is that after I download an image to my Downloads folder, the script or action automatically moves that image to a different, pre-specified folder. I don't want to right click and run a job, I want this to work without me telling it to do so on a case-by-case basis. If that's too hard, I could live with this job running on a schedule I set up with Cronnix or similar.

Vie Google, I've seen examples of how to do this for all items in a given folder, and I've seen an example of how to do this while selecting files on the fly, but what I want is a standing rule that says "all files of types x and y are moved to folder z," and just does this with no further intervention on my part.

It's gotta be easy-peasy and I'm over-thinking this, right?
posted by mosk to Computers & Internet (5 answers total) 1 user marked this as a favorite
 
Best answer: Any reason why you wouldn't write this as a shell script and have cron run it periodically?
#!/bin/sh
cp ~/Download/*.{jpg,gif} ~/Downloaded\ Images 2> /dev/null

posted by seliopou at 2:30 PM on January 15, 2010


Response by poster: > Any reason why you wouldn't write this as a shell script and have cron run it periodically?

Thanks, that was quick! It looks like that would work just fine. I tend to steer clear of shell scripts out of ignorance, but if I don't try I won't learn.

I'm still going to leave this open for a bit and hopefully gather some more examples. I would still like to know how to do this in Automator and/or AppleScript.
posted by mosk at 2:41 PM on January 15, 2010


Best answer: I just made one up that seems to be working properly.

1. Filter Finder Item.
I then set the filter to find file where ANY of the following are true:
File extention ends with jpg (do not ad the period ex. .jpg)
File extention ends with jpeg
File extention ends with tif
File extention ends with tiff

2. Move finder Items.

That's it. You do not need a get finder items command as you are attaching this as a folder action.
posted by travis08 at 3:10 PM on January 15, 2010


Best answer: You should use LaunchD instead of Cron. On that note, I suggest using late (!) Lingon. Just paste the second line from seliopou into the "What" section. Then set the "Run it if this file is modified:" section to "/Users/[your short username]/Downloads/". This will run the script every time something is put into or taken out of the downloads folder. Do not use the "Run it if anything is placed into this folder" section.
posted by 47triple2 at 3:17 PM on January 15, 2010


Response by poster: These are great and exactly what I was hoping for! Thanks! "Filter Finder Items" was the step I was missing and didn't see; thanks, travis08.

Thanks for the tips on the shell script and Lingon. I will dig deeper on those and try to learn a thing or two.
posted by mosk at 3:40 PM on January 15, 2010


« Older 3 different rooms so 3 different rents?   |   You say "validation," they say "verification".... Newer »
This thread is closed to new comments.