batch file renaming

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

  1. hakuryuu macrumors 6502

    Sep 30, 2007
    Lomita, CA
    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


    Dec 10, 2008
    Northern California
    Just create a text file, call it "" 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

    To run it from Terminal, type:


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

  3. yoyo5280 macrumors 68000


    Feb 24, 2007
    Melbourne, Australia & Bay Area
    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!

  4. angelwatt Moderator emeritus


    Aug 16, 2005
  5. hakuryuu thread starter macrumors 6502

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

    Aug 26, 2009
    Similar query...


    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


Share This Page