Batch rename files

Discussion in 'Mac Programming' started by pulsewidth947, Jun 2, 2007.

  1. pulsewidth947 macrumors 65816


    Jan 25, 2005
    I have a load of mp4s that I've made. I have them all sorted by order but I'd like to tag on episode names at the end of them. Is there anyway to take a list and add it on to the end of a file? For example, my files are named s01e01, s01e02, etc. My list is as follows Pilot, New Beginnings, etc. Each new list item is on a new line.

    Hope that makes sense.
  2. iSee macrumors 68040


    Oct 25, 2004
    So you want to rename "s01e01.mp4" to "s01e01 Pilot", and "s01e02.mp4" to "s01e02 New Beginnings.mp4," etc.?
  3. pulsewidth947 thread starter macrumors 65816


    Jan 25, 2005
    That's correct. I asked this question on MacScripter and someone provided the following code:
    set titleList to paragraphs of (read (choose file with prompt "Choose file which contains the title list" without invisibles))
    set theFolder to choose folder

    tell application 
    "Finder" to set these_files to files of theFolder
    repeat with i from 1 to count these_files
    {name:Nmname extension:Exto info for (item i of these_files) as alias
    if Ex is missing value then set Ex to ""
    if Ex is not "" then
           set Nm to text 1 thru 
    ((count Nm) - (count Ex) - 1of Nm
           set Ex to 
    "." Ex
    tell application "Finder" to set name of item i of these_files to Nm "_" item i of titleList Ex
    end repeat
  4. HiRez macrumors 603


    Jan 6, 2004
    Western US
    AppleScript would be the easiest way, just make sure you back everything up before you run something like that.
  5. pulsewidth947 thread starter macrumors 65816


    Jan 25, 2005
    Absolutely. Automator is nice for basic renaming but thats about it. I tested the script on a copy of the files until I knew it worked.
  6. Jeephead macrumors newbie

    Jul 15, 2007
    Problem with names when importing photos.

    I have a problem when I import photos. Most of my photos are correct as in DSC_5007.NEF/DSC_5009.JPG. How-ever lately most of my pictures get imported as _DSC6011.NEF/_DSC6011.JPG. I have checked my camera to make sure nothing has been changed and it appears to be correct.
    My work flow goes like this - Basically I import my photos with iPHOTO, then I make a copy off my memory card to a separate external hard drive, then I burn a DVD back-up. Now I have a disaster recovery disk of original un-edited pics, an external hard drive in which to store working copies and I use iPHOTO for viewing pictures for editing in Elements. Once I edit pictures I rename them and send them to a separate folder called "Finished Picture". Now that final folder gets FTP'd to yet a different external server in my basement. I know it might sound a little overboard but I have lost pictures in the past like everyone else and do not plan to let it happen again.
    Anyway, what I want to do is rename the files that are messed up for my archive of original picture. I want to maintain the original naming DSC_6100.NEF/DSC_6100.JPG without having to manually re-type each one.
    I tried to set up Automator to do this for me, say look for any file that has this beginning format "_DSC" and change it to "DSC_". Is this possible or is there something out there that works better. It would be nice to find out why when I import the name is getting changed. Any help would be great. I am using a Power PC 1.8GHz iMAC with 1 Gig ram.
  7. HiRez macrumors 603


    Jan 6, 2004
    Western US
    It's certainly possible and not complicated to do this with an AppleScript, but it sounds like perhaps the color space settings got changed in your camera (from sRGB to Adobe RGB 1998), which apparently can result in a different naming prefix (sounds like a camera software bug). This link explains it. There are also existing freeware and shareware applications that can batch rename files and folders. Check VersionTracker.
  8. Jeephead macrumors newbie

    Jul 15, 2007
    Colour space..

    Hirez...Thanks!!! I went into my camera settings and found that colour space had been changed to type II Adobe1998 instead of sRGB. I will shoot some test shots to see.
    Thanks again!!
  9. riscy macrumors 6502a


    Jan 4, 2008
    Also, for regular batch renaming of files there is Name Mangler which I find works really well.

Share This Page