• Welcome to the Lightroom Queen Forums! We're a friendly bunch, so please feel free to register and join in the conversation. If you're not familiar with forums, you'll find step by step instructions on how to post your first thread under Help at the bottom of the page. You're also welcome to download our free Lightroom Quick Start eBooks and explore our other FAQ resources.
  • Stop struggling with Lightroom! There's no need to spend hours hunting for the answers to your Lightroom Classic questions. All the information you need is in Adobe Lightroom Classic - The Missing FAQ!

    To help you get started, there's a series of easy tutorials to guide you through a simple workflow. As you grow in confidence, the book switches to a conversational FAQ format, so you can quickly find answers to advanced questions. And better still, the eBooks are updated for every release, so it's always up to date.
  • 16 April 2026 It's Lightroom update time again. There are some new features, as well as bug fixes, new cameras and lenses.
    See What’s New in Lightroom Classic 15.3, Mobile & Desktop (April 2026)? for more details.

Batch rename

Status
Not open for further replies.

brian_mk

New Member
Joined
Dec 11, 2017
Messages
12
Lightroom Experience
Intermediate
Lightroom Version
Lightroom Version Number
13.1
Operating System
  1. Windows 10
For historical reasons I have a large number of scanned film images in LR with filenames in the following format:-
<subject description>_<collection id>_<frame no>.tif

For scanned negative film (B&W or colour):-
<collection id> is a unique three digit number representing the film roll id
<frame no> is a two digit number representing the frame number within the roll.

For scanned slides:-
<collection id> is a unique three digit number representing a batch of slides relating to a particular trip / location / subject.
<frame no> is a two digit number representing the number stamped on the slide mount.

An example might be something like:-
BleaTarn_376_06.tif

I have a separate searchable MS Access database (created long before LR existed) that contains metadata for each <collection id>
That includes things like date, location, film type, film processing details etc.

The problem with the existing filename format is that when listing the files using most file managers such as Windows Explorer, the default sort order is based on the alphanumeric <subject description> string.
Ideally I would like to change the order of the fields to

<collection id>_<frame no>_<subject description>.tif
e.g. 376_06_BleaTarn.tif

I could do this quite easily in Windows using a custom script or 'Bulk Rename Utility.exe'.
However it needs to be done within LR to preserve the catalogue, existing edits etc.
It would take an age to change every filename one at a time in LR.
I have looked into LR Batch Rename but cannot see a way to do what I want.

Any ideas?
 
I haven't looked to deeply into John Beardsworth's http://lightroomsolutions.com/plug-ins/search-and-replace/ plugin but if it does not do what you want, I'm thinking that John could help you parse the file name and replace it as you desire. Take a look into his plugin and give him a shout.
 
In an ideal world, LR would include a tool that allows the user to create customised regular expressions to rename files rather like the Windows 'Bulk Rename' utility.
It offers a pretty comprehensive way to rename multiple files:-

1768066680378.png
 
In an ideal world, LR would include a tool that allows the user to create customised regular expressions to rename files rather like the Windows 'Bulk Rename' utility.
It offers a pretty comprehensive way to rename multiple files:-

View attachment 27911
Windows 'Bulk Rename' utility only works with the file system Your file name is in two places. The Filesystem AND the Lightroom catalog. That is why I recommended John's plugin or a modified version of one. The File name is stored in the Lightroom Catalog. This is a SQLite data base you could write a SQL script that would modify the File Name Column in the database table. However this would not change the file name in the filesystem. Another script would need to be constructed to modify the file name in the filesystem identical to the parsing done in the Lightroom database.
 
Last edited:
I haven't looked to deeply into John Beardsworth's http://lightroomsolutions.com/plug-ins/search-and-replace/ plugin but if it does not do what you want, I'm thinking that John could help you parse the file name and replace it as you desire. Take a look into his plugin and give him a shout.

See this article http://lightroomsolutions.com/articles/complex-file-renaming-in-lightroom-made-simpler/ . The trick is to copy the existing filename into a field which LR's renaming tool can access (eg headline), search and replace within that field, and then rename the files.
 
While I haven’t used the Search and Replace plugin for exactly this kind of renaming, I have used it extensively to append and prepend strings to filenames of images managed by Lightroom. It's a very useful plugin for all sorts of things.
 
For when the built-in F2 file rename tool can’t handle it

Use “jb Search + Replace” plug in. https://photographers-toolbox.com/products/jbeardsworth/findreplace/

  1. Select images

  2. Use plug-in to copy file name to “Headluine” Metadata field
    1768067820579.png

  3. Use any method you wish to fix the text in the “Headline” field. Below is an example using the same plugin
    1768067845037.png
  4. use the LrC File rename tool (Fn2) to rename file from Headline
    1768067880577.png


    1768067907164.png
 
Beardsworth's Search and Replace plugin indeed can do this, though there are quite a few steps. For the purpose of this demo, I'm going to assume that in your <subject description>_<collection id>_<frame no>.tif scheme, _<collection id>_<frame no> is always of the form "_xxx_yy" is always 7 characters in length, as that's how I understood what you said in your original post.

Here's the basic idea:
  1. Copy the filename without extension into the Headline field (assuming you aren't using this field for anything else)
  2. Copy the filename without extension into the Instructions field (assuming you aren't using this field for anything else)
  3. Modify the Headline field to strip off the <subject description> leaving _<collection id>_<frame no>
  4. Modify the Instructions field to strip off the _<collection id>_<frame no> leaving <subject description>
  5. Modify the Headline field to strip off the leading underscore, leaving only <collection id>_<frame no>
  6. Use Lightroom's built in file rename feature to change the filename to <collection id>_<frame no>_<subject description>
Here are some screenshots showing each of these steps.
This is what the meta-data panel shows as the file name before starting:
SCR-20260110-FP0.png

1. Run Search and Replace to transfer the filename without extension into the Headline field
SCR-20260110-FP2.png

2. Run Search and Replace to transfer the filename without extension into the Instructions field
SCR-20260110-FP1.png

3. Run Search and Replace to strip off all but the last 7 characters from Headline, leaving only _<collection id>_<frame no>
SCR-20260110-FP4.png
(the way John has written the plug-in what the step is doing is to replace ALL BUT the last 7 characters with a blank)

4. Run Search and Replace to strip off the last 7 characters from Instructions, leaving only the <subject description>
SCR-20260110-FP3.png
(the way John has written the plug-in what the step is doing is to replace the last 7 characters with a blank)

5. Run Search and Replace to strip off the leading underscore, leaving only <collection id>_<frame no>
SCR-20260110-FP5.png
(the method is a bit convoluted… I would've thought that it would work to use replace x to y chars with "1 to 1" but that didn't seem to work, so I changed it to replace all but the last 6 characters, i.e., the first character, the underscore, with a blank)

At this point, this is what the Instructions and Headline metadata fields look like in the metadata panel:
SCR-20260110-FP6.png

6. Use Lightroom's built in file rename feature to change the filename to <collection id>_<frame no>_<subject description>
SCR-20260110-FP7.png
Finally, after doing the rename, here's the result:
SCR-20260110-FP8.png
 
This has inspired me to write a plug-in designed specifically to make this much easier. You give it a lua string matching pattern, replacement and the metadata field you want to store it in (eg. headline, job identifier, etc). It then updates that metadata field with the new filename for each file in the selection. Then using the LrC batch rename you select a that metadata field and all the files get renamed accordingly.

For example, to target files names like BleaTarn_376_06.tif and rename them to 376_06_BleaTarn.tif the pattern is ^(.*)_(%d+)_(%d+)$ and the replacement is %2_%3_%1

The plugin ignores the file extension so the pattern only applies to the filename portion. The pattern above tells it to find any number of characters prior to an underscore then two sets of digits separated by underscores. If a file name matches that pattern it rearranges the elements so the two sets of digits precedes the original starting characters.

A bit geeky but powerful enough to transform most any file name that fits a regular pattern of some sort.

Anyway, I've got the plug-in working and just need to clean it up, add some additional error handling, documentation, etc. I should have it ready in a few days and will provide a link here if anyone wants it.
 
I have been asked to implement string matching in Search and Replace a few times over the years, but I have always resisted. Only a tiny proportion of photographers have the faintest idea what pattern or voodoo they would be typing in, or think ahead about the damage they can do to their metadata and even to their filenames. Those with problems in their filenaming also tend to have inconsistencies that they only remember too late! And guess who gets blamed for the self-inflicted mess? Far better to force folk to make such changes step by step, reviewing what they've done before proceeding. I'd love it if Lightroom had a string substitution feature in its renaming tool, just like Bridge has always done, but renaming files in bulk is too important to be made easy.
 
I can see sense in John’s comments… but also see the need at times to be able to restructure filenames without manually typing or writing code.

As admin of many camera club competitions , despite best endeavours to coax members to properly format entries… invariable we get large volumes of images electronically where the file names are a serious mess and a nightmare to rename… so I have been around this loop a few times.

I am happy that I have a stable image file/folder naming schema.. so do not need to mess with my images or their filenames.

If I need to rename files for a competition… all images are stored in a specific folder, so any bulk processing is limited to this single folder.. I then try to get the revised filename into the State field (which is both editable and sortable). I may consider keeping everything in a dedicated catalog, depending on volume.

I then sort the entries by State and check if any anomalies jump out. I can use ListView or similar to list the original filename and the revised name in the State field side by side, so I can view them. Mostly I do not need to rename… as I can use the State field to sort as per the revised / desired filename. It is also possible to edit the State field for the real oddball filename exceptions.
 
I have been asked to implement string matching in Search and Replace a few times over the years, but I have always resisted. Only a tiny proportion of photographers have the faintest idea what pattern or voodoo they would be typing in, or think ahead about the damage they can do to their metadata and even to their filenames. Those with problems in their filenaming also tend to have inconsistencies that they only remember too late! And guess who gets blamed for the self-inflicted mess? Far better to force folk to make such changes step by step, reviewing what they've done before proceeding. I'd love it if Lightroom had a string substitution feature in its renaming tool, just like Bridge has always done, but renaming files in bulk is too important to be made easy.

I agree 100% but still think it's worthwhile for advanced users and perhaps it will be less likely for a mistake if there aren't many steps to perform. To try to guard against mistakes, the plug-in requires you to select the images and only updates a few possible metadata fields. I purposely chose not to include all possibilities. Also, it reports exactly what it has done and you can undo all the metadata updates (of course not if you quit LrC), select all the photos again and clear the metadata field or simply choose not to do the final LrC batch rename.

I don't mean to step on your plug-in's "toes" and it isn't intended to be a general purpose utility like Search and Replace. But I thought a very targeted plug-in that does just one thing might be useful for certain situations.
 
I agree 100% but still think it's worthwhile for advanced users and perhaps it will be less likely for a mistake if there aren't many steps to perform.
I also think there are other advanced users that can always help those in need of expertise. Why else would we have forums such as these?
 
FYI...John Beardsworth has just released version 3.4.0 of his Search + Replace plugin. It now supports using x to y chars with x = y, thus permitting one to replace a single character at the xth position. This makes my step 5 (in post #10) much simpler. Thanks, John!
 
I've posted the new file name transformer plug-in we discussed in this thread. I've tried to be defensive in providing reasonable defaults and validating patterns and replacements. It also provides a summary of the results along with a link to the log file if there were files that didn't match or there is some sort of error.

I'm hoping the plug-in is helpful for cases where pattern matching is needed on a batch of file names in order to rename them.

It's essentially just a two step process:
  1. Select the photos and enter a pattern and replacement. In the OP's example to transform from BleaTarn_376_06.tif to 376_06_BleaTarn.tif:
    Pattern: ^(.*)_(%d+)_(%d+)$
    Replacement: %2_%3_%1

    You'll get a results dialog showing the number of photos that matched the pattern and didn't match the pattern. In the case where there are any that didn't match you'll get a link to the log file that has all their full paths so you can investigate.

    Importantly, nothing has happened beyond the specified metadata field for each photo has been updated. You can revert all of that with a single Undo.

  2. If the metadata field (by default Job Identifier) contains the new file names as you expected then use Library > Rename Photos (F2). Create a preset that only uses the contents of that metadata field (eg. Job Identifier) and do the batch rename.
The plug-in is called Namely and can be downloaded from https://jrobnz.dev/lightroom/

Feedback and suggestions are welcome
 
Status
Not open for further replies.
Back
Top