batch file renaming

Discussion in 'macOS' started by hakuryuu, Aug 10, 2009.

  1. hakuryuu macrumors 6502

    Joined:
    Sep 30, 2007
    Location:
    Lomita, CA
    #1
    So in windows I can create a file list, save it to a text file, and create a .bat file with rename commands for each file. for example:

    Rename 000055-060409232023-CAM1.jpg cal000image0000055.jpg
    Rename 000056-060409232020-CAM1.jpg cal000image0000056.jpg
    Rename 000057-060409232016-CAM1.jpg cal000image0000057.jpg
    Rename 000058-060409232012-CAM1.jpg cal000image0000058.jpg
    Rename 000059-060409232008-CAM1.jpg cal000image0000059.jpg
    Rename 000060-060409232004-CAM1.jpg cal000image0000060.jpg
    Rename 000061-060409232001-CAM1.jpg cal000image0000061.jpg
    Rename 000062-060409231957-CAM1.jpg cal000image0000062.jpg
    Rename 000063-060409231953-CAM1.jpg cal000image0000063.jpg

    So my question is how do I create a file list and then create a way to batch rename in os x? I know the commands, but I don't know of a way to do it on more than one file at a time. I have found a few renaming apps but they all appear to be focused on just iterating up instead of renaming specific files to a new name.
     
  2. sidewinder macrumors 68020

    sidewinder

    Joined:
    Dec 10, 2008
    Location:
    Northern California
    #2
    Just create a text file, call it "rename.sh" for now, with these lines:

    mv 000055-060409232023-CAM1.jpg cal000image0000055.jpg
    mv 000056-060409232020-CAM1.jpg cal000image0000056.jpg
    mv 000057-060409232016-CAM1.jpg cal000image0000057.jpg
    mv 000058-060409232012-CAM1.jpg cal000image0000058.jpg
    mv 000059-060409232008-CAM1.jpg cal000image0000059.jpg
    mv 000060-060409232004-CAM1.jpg cal000image0000060.jpg
    mv 000061-060409232001-CAM1.jpg cal000image0000061.jpg
    mv 000062-060409231957-CAM1.jpg cal000image0000062.jpg
    mv 000063-060409231953-CAM1.jpg cal000image0000063.jpg

    Then use the terminal to add the execute bit:

    chmod +x rename.sh

    To run it from Terminal, type:

    ./rename.sh

    This all assumes the shell script is in the same dir as the files. Adjust accordingly.

    S-
     
  3. yoyo5280 macrumors 68000

    yoyo5280

    Joined:
    Feb 24, 2007
    Location:
    Melbourne, Australia & Bay Area
    #3
    Open up automator. Find something like get finder items. Then find the Rename finder items.

    Press run. Your done.

    Now save it as an app, and never have to deal with code again!

    -Omi
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
  5. hakuryuu thread starter macrumors 6502

    Joined:
    Sep 30, 2007
    Location:
    Lomita, CA
    #5
    awesome. thanks! I knew it couldn't be too hard.
     
  6. RandmTask macrumors newbie

    Joined:
    Aug 26, 2009
    #6
    Similar query...

    Hi

    Similar question

    If I had a list of filenames in a text file like such (without the extension)

    1.1 Welcome
    1.2 Introduction
    2.1 The Basics
    2.2 etc
    2.3 etc
    ...
    ...
    12.14 etc

    how would I go about renaming a folder worth of files. The files are currently named 1.1.pdf, 1.2.pdf etc

    New to a mac, still finding my way round :D

    cheers
     

Share This Page