View Full Version : AppleScript help needed
rendezvouscp
Jun 29, 2004, 04:10 PM
I'm working on an AppleScript right now, and I'd like to be able to add ".jpg" to all of the files in a folder. How do you apply an action like that to make it a folder script? Thanks in advance.
–Chase
tomf87
Jun 30, 2004, 01:09 PM
It may be easier to use Terminal. Something like this from osxfaq.com:
http://www.osxfaq.com/tips/unix-tricks/week40/thursday.ws
EDIT:
Here's modification of their code for your use:
#!/bin/bash
for fn in `find . -type f | grep -v '.jpg' | grep -v 'batch-rename.sh'`
do
mv $fn `basename $fn.`jpg
done
This will modify all filenames in current folder and subfolders, except for anything that has .jpg or batch-rename.sh in the filename, and append .jpg to them. I named my script batch-rename.sh so that's why it is in there. If you want AppleScript to launch this shell script, use, assuming batch-rename.sh is in a folder named bin in your home directory:
do shell script "~/bin/batch-rename.sh"
Save this as an AppleScript under /Library/Scripts/Folder Action Scripts
Now you should be able to select that in Finder for that particular folder.
DISCLAIMER: This script has been tested minimally, and I am under no liability for any result or action this script may do. I highly recommend testing this on a temporary directory before actual use.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.