Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

peeluseeds

macrumors newbie
Original poster
Mar 9, 2009
2
0
Hi everyone,

I'm trying to figure out a way (with Automator, ideally) to have a script look through a folder and create a new folder for each item. for example:

-search through folder for all files with EPS extension
-for each EPS file, create folder with name of the EPS file (minus extension)
-move EPS file into created folder.

I hope automator can do this!

Thanks for the help!
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
I am not the best with applescript or automator, but with shell:
Code:
ls *.eps | awk -F'.eps$' '{print "mkdir "$1"; mv "$0" "$1"/"}' | sh

In general, always back up anything before you run a script you write, or you get from an untrustworthy source (like the internet), etc.

ls *.eps will give you a list of files that end with .eps. The awk command tokenizes on .eps<end of line>, and prints "mkdir <filename without eps>; mv <filename> <filename without eps>/", and sending that to sh will execute that command. You can accomplish the last bit using system() in awk instead, but i always like to print and see what's going to happen first, and it's always easy to just pipe it to sh instead of changing it to system.

-Lee
 

peeluseeds

macrumors newbie
Original poster
Mar 9, 2009
2
0
This is great! Exactly the type of thing I was hoping for.

Thank you very much, Lee!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.