AppleScript help needed

Discussion in 'Mac Apps and Mac App Store' started by rendezvouscp, Jun 29, 2004.

  1. rendezvouscp macrumors 68000

    Joined:
    Aug 20, 2003
    Location:
    Long Beach, California
    #1
    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
     
  2. tomf87 macrumors 65816

    tomf87

    Joined:
    Sep 10, 2003
    #2
    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.
     

Share This Page