Complex File Renaming – using Search & Replace
I had an interesting email from someone who uses my Search and Replace plug-in for Lightroom:
… I need to remove text (“Scan_”) from the filename for images I scanned 4-5 years ago (and are now in my LR catalog). It appears Search and Replace does not work on filenames, only on metadata. Pre-LR catalog I used a utility to do bulk file name changes on folders of files, but that will be a problem with the LR catalog. I could use the bulk filename changing tool, then delete the LR-cataloged-but-missing-image and then reimport the newly rename files. But it seems risky and I’d lose metadata for the images w/o XMP files.
Replacing text in filenames is a common need and for example Adobe Bridge’s renaming dialog box does it with its “string substitution” option – see the bottom of this article.
But this capability has never been available in Lightroom. I suspect it is as simple as Bridge’s “string substitution” only introduced during Lightroom’s early days and it was overlooked when batch rename was designed. And sadly, this omission has never been rectified, even 13 years after I started whining to Adobe about it….
So I began my reply by saying that Search & Replace couldn’t help with file renaming because plugins can’t rename photos. In other words, “Computer says No” (Little Britain, if the reference isn’t clear!). But all of a sudden, the solution revealed itself….
The method
- Use Search & Replace’s Transfer command to copy the file name to an unused field which Lightroom’s Batch Rename dialog can access – I suggest Headline
- Use Search & Replace Replace tab to remove “Scan_” from Headline or whatever field you choose
- Finally use LR’s Rename Photos command to rename the files using the field in the renaming template
It’s a whole lot easier than I ever thought it might be!
“String Substitution” in Bridge
Warning: this method removes any pick flags, stacking, VCs , collections, history steps applied to the files:
- In Lightroom, save the metadata back to the files – Ctrl or Cmd S
- In Bridge, select the files and use Batch Rename
- In its New Filenames section, select the option String Substitution
- Next line down is where you choose what to find and what to replace it with
- In Lightroom, synchronize the folder – this will remove the -Edit files and import the renamed versions