Ever spend ages thinking up ways to convince someone a task is far from easy, and that they should just give up on the idea – and then the solution appears just as you were about to hit the Send button?

Well, the other night I had an interesting email from someone who has 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.

It’s not at all unreasonable that users would want to replace certain text when doing a batch rename – I often used the feature in iView/Expression Media – and it’s a shame that Lightroom’s renaming seems to have fallen foul of  “you couldn’t do it in Bridge” thinking here. It is a bit underpowered in this respect, especially as changing file names outside Lightroom can easily do a lot more damage – you could lose a lot of your work.

So I began my reply saying I wouldn’t be adapting Search & Replace to handle file renaming, as it is indeed for metadata manipulation and its next steps are most likely to be into spell checking. I then wrote a couple of lengthy paragraphs explaining how a dedicated file renaming plug-in could certainly be written, but doing it well would be time-consuming and still risk scrambling the user’s file system and trashing a lot of Lightroom work. The user’s idea of reimporting the renamed files was workable if you weren’t worried about losing all the Lightroom work that isn’t stored in the XMP – flags, stacks, virtual copies, assignment to collections, and history steps. In a final flourish of negative thinking I began to think about how to explain running the external renaming utility and then updating the catalogue via SQL? Again it’s conceivable – but a lot of work. You might summarise my response as “Computer says No” (Little Britain, if the reference isn’t clear!).

Using Search and Replace on an IPTC field, it's possible to perform more complex renaming than Lightroom's Batch Rename permits

And then I realised how simple it would be:

  1. Use Search & Replace’s Transfer command to copy the file name to any unused IPTC field that Lightroom’s Batch Rename dialog will be able to access. Let’s say it’s the Headline
  2. Use Search & Replace to remove “Scan_” from the Headline
  3. Use Search & Replace to remove the extension from the Headline
  4. Finally use LR’s Rename Photos to rename using the Headline

Easy.