Author Topic: Batch rename with substring  (Read 5419 times)

Offline juji

  • Newcomer
  • *
  • Posts: 13
    • View Profile
Batch rename with substring
« on: September 09, 2011, 08:51:48 AM »
Hi

I've been struggling for some time on how to change the names of thousands of images to fit a new format for a client.

I have several thousand photos with the filename in this format:

YYYY#.Code$.Description$.n.Source$.jpg - eg 1950s.E333.Arrival.1.Times.jpg, or 1950c.E333.Arrival.1.Times.jpg, or 1950.E333.Arrival.1.Times.jpg.

New format:

YYYY#_Source$.jpg (note the '_'), with a maximum of 21 characters, tracking the old filename in one of the metadata fields.

This is how I've done it:

1. Using IPTC Stationary Pad, I saved the file name base to the 'Caption Writer' (or wherever) field, using the Variable {fbas}.

[Kirk, is there a way of adding Photo Mechanic custom fields such as 'Old Filename' to the IPTC data? For example, iView Media has custom fields].

2. I then used Edit>Find and Replace, to replace '.' with '_' in the 'Caption Writers' field.

3. I sorted the files into different folders by the Source$ (eg 'NIS-Sun', or 'Times', for example). This meant I could control the number of characters for the substring extraction.

4. Next, I renamed the file name from the Caption Writer field using the Variable {cwrt} in Rename Photos.

5. Reopening Rename Photos, I entered the following substring to extract 'YYYY_Source$.jpg' (or 'YYYY#_Source$.jpg').

{fbas:0,4}_{fbas:-n} - for YYYY, where 'n' is the number of characters from the end. For 'Times' it would be {fbas:-6}, (5 characters for 'Times' and one extra for the '_').

(or {fbas:0,5}_{fbas:-n} - for YYYY#)

It has the desired outcome. Perhaps there is a way to do all this with an AppleScript? Well, if you (Kirk and others) know about this, do feel free to advise me.

Thanks.
« Last Edit: September 09, 2011, 09:35:33 AM by juji »

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 25020
    • View Profile
    • Camera Bits, Inc.
Re: Batch rename with substring
« Reply #1 on: September 09, 2011, 09:31:37 AM »
Hi

I've been struggling for some time on how to change the names of thousands of images to fit a new format for a client.

I have several thousand photos with the filename in this format:

YYYY#.Code$.Description$.n.Source$.jpg - eg 1950s.E333.Arrival.1.Times.jpg, or 1950c.E333.Arrival.1.Times.jpg, or 1950.E333.Arrival.1.Times.jpg.

New format:

YYYY#_Source$.jpg (note the '_'), with a maximum of 21 characters, tracking the old filename in one of the metadata fields.

This is how I've done it:

1. Using IPTC Stationary Pad, I saved the file name base to the 'Caption Writer' (or wherever) field, using the Variable {fbas}.

[Kirk, is there a way of adding Photo Mechanic custom fields such as 'Old Filename' to the IPTC data? For example, iView Media has custom fields].

2. I then used Edit>Find and Replace, to replace '.' with '_' in the 'Caption Writers' field.

3. I sorted the files into different folders by the Source$ (eg 'NIS-Sun', or 'Times', for example). This meant I could specify the number of characters.

4. Next, I renamed the file name from the Caption Writer field using the Variable {cwrt}.

5. In Rename Photos, I used the following substring to extract YYYY_Source$.jpg (or YYYY#_Source$.jpg).

{fbas:0,4}_{fbas:-n} - where 'n' is the number of characters from the end.
{fbas:0,5}_{fbas:-n}

It has the desired outcome. Perhaps there is a way to do all this with an AppleScript? Well, if you (Kirk and others) know about this, do feel free to advise me.

No AppleScripting of Photo Mechanic.  Six custom variables in the User/Client dialog.  See page 60 of the manual.

-Kirk