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?
Best answer: Can't help you with the Applescript, but if you open a terminal you should be able to do this with bash:
posted by flabdablet at 8:10 PM on October 17, 2007 [10 favorites]
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
posted by 40 Watt at 8:33 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]
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:
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
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
This thread is closed to new comments.
posted by 40 Watt at 8:03 PM on October 17, 2007