Skip navigation

Can I batch rename to remove prepended characters?

1011 Views 14 Replies Latest reply: Apr 19, 2013 1:28 PM by aquestionortwo RSS
aquestionortwo Level 1 Level 1 (0 points)
Currently Being Moderated
Apr 16, 2013 8:14 AM

I know the basics of batch renaming files, but can't seem to figure out if this is possible:


I have a number of files scattered across different projects and folders.

These files are named ABC-DEF-xxxxxxx

The xxxxxxx is unique to each file, and non-sequential (sometimes just text words).


So I am wondering is if there a way to batch remove the "ABC-DEF-" from the master file name and leave everything else in the name unchanged?

I should say...without doing a tremendous amount of work like exporting the files from Aperture, changing the names somehow, then re-importing (which I think would be lots of work, esp since the files are scattered across different projects/folders).



Thanks much everyone!

Mac Pro, Mac OS X (10.6.8), Time Capsule
  • Frank Caggiano Level 7 Level 7 (22,890 points)

    Could be done with scripting but I don't think the builtin Aperture renaming tools would be able to do it.


    If you could supply a few actual examples of the version names (the actual name cut and pasted here)  and what exactly you want changed I might be able to have a look at it latter today if no other solution comes up.




  • Kirby Krieger Level 6 Level 6 (11,590 points)

    Can't be done with Aperture, afaik.  I use a macro utility (Keyboard Maestro) that copies to the clipboard and edits clipboard contents, to change the Version name.  I then use Aperture to write the Version names back over the Originals.  I'm sure someone skilled could make something iterative and perhaps even one-buttony .


    OP:  I think this suggests a well-designed and implemented file naming scheme.  For your existing Originals, it might be easier to remove the prefixes after you export (and just leave your current Originals as they are).  As Frank suggests, if you provide specifics you'll likely get  more tailored answers.


    Message was edited by: Kirby Krieger -- cleanage.

  • Frank Caggiano Level 7 Level 7 (22,890 points)

    They all start with MIN-CAL- ?

  • phosgraphis Level 2 Level 2 (285 points)

    Is your Aperture library managed or referenced?

  • Frank Caggiano Level 7 Level 7 (22,890 points)

    This script will rename all the selected versions in the form XXX-YYY-FinalName to FinalName


    Doesn;t matter what XXX and YYY are or how long they are as long as the format is exactly three groups of chars separated by a dash.


    tell application "Aperture"


              set imageList to (the selection)

              if imageList is {} then

                        error "Select IMages."

              end if


              set {oldTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "-"}

              repeat with i in imageList

                        set n to (name of i)

                        set name of i to text item 3 of n

              end repeat

              set AppleScript's text item delimiters to oldTID

    end tell


    to run it select all the text in the box above right click it and select make new applescript. This will copy the script into the AppleScript editor.


    Start Aperture and select the images you want to rename.  I strongly advise you do this first on a test library to make sure it is doing want you want. Export some of the images as a new library and test with that.


    Note this will only change the version names no the original file names. If you also want to change the original file names once the versions are renamed select them and run  MetaDatat->Batch Change. Select Version Name Format: Current Version Name and select the Apply to Originals checkbox.

  • phosgraphis Level 2 Level 2 (285 points)

    Try Frank's script. Since all your names start with the same characters, that's the best way to go with a managed library. Frank's precautions are seconded.

  • Frank Caggiano Level 7 Level 7 (22,890 points)

    So have you tried the script?

  • léonie Level 8 Level 8 (46,700 points)

    Nicely done Frank, to use the "-" as text item delimiter . I was thinking of dropping the first 8 characters of each filename, but I like your way much better!

  • Kirby Krieger Level 6 Level 6 (11,590 points)
    Currently Being Moderated
    Apr 19, 2013 10:54 AM (in response to léonie)

    Aha -- now even I get it.  Sweet.  ;-)


    (Sent from my magic glass.)

  • Frank Caggiano Level 7 Level 7 (22,890 points)
    Currently Being Moderated
    Apr 19, 2013 11:07 AM (in response to léonie)



    Yeah, I don't know if they designed it with this in mind but there are a bunch of things you can do by messing with the text item delimiters.


    Really reduces the need for regexps, I almost don't miss them in AppleScript



    Just like a ta-da moment


    Still on the magic glass? Did you get the macbook back yet?


More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.