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

rendezvouscp

macrumors 68000
Original poster
Aug 20, 2003
1,526
0
Long Beach, California
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

macrumors 65816
Sep 10, 2003
1,052
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.