Help me batch process files and folders with Applescript
October 17, 2007 8:01 PM   Subscribe

I have a folder of about two thousand .png files. For each file, I need to (1)create a new folder named the same as the currently selected file(minus the extension), and (2)move the file into its eponymous folder. How can I accomplish this using Applescript?
posted by 40 Watt to Computers & Internet (7 answers total) 3 users marked this as a favorite
 
Response by poster: I'm kinda new to Applescript, although I've used it for some minor tasks. I'm able to make a folder but I can't figure out the syntax to copy the name from the current file to the folder.
posted by 40 Watt at 8:03 PM on October 17, 2007


Best answer: Can't help you with the Applescript, but if you open a terminal you should be able to do this with bash:

for f in *.png; do mkdir "${f%.png}"; mv "$f" "${f%.png}"; done

posted by flabdablet at 8:10 PM on October 17, 2007 [10 favorites]


Response by poster: See, this is why I freakin' love AskMe. Here I was trying to make it all complicated-like. Thanks, flabdablet!
posted by 40 Watt at 8:33 PM on October 17, 2007


flabdablet, that was hot.
posted by limon at 8:48 PM on October 17, 2007


Response by poster: agreed. I'm all tingly.
posted by 40 Watt at 8:52 PM on October 17, 2007


flabdablet, that was hot.

Bash scripting for fun and (sexual?) profit
posted by chrisamiller at 8:59 PM on October 17, 2007 [1 favorite]


Drunk with unexpected kudos, the lad immediately descends into showing off... here's the Windows XP cmd equivalent:

for %F in (*.png) do (
mkdir "%~nF"
move "%~F" "%~nF"
)

Yes, it does need to be entered as multiple lines, and if you put this in a batch file, use %% instead of % throughout.
posted by flabdablet at 11:20 PM on October 17, 2007


« Older Is it healthier to wait after cutting garlic...   |   Cash or carry? Newer »
This thread is closed to new comments.