Need LEFT(), RIGHT(), MID() functions in LR batch renaming

  • 4
  • Idea
  • Updated 6 years ago
I have a critical need in LR 4 for the rename process to include LEFT(), MID() and RIGHT() functions, or something similar, to allow including specific portions of the existing image file name in the new file name.

I am in the process of using LR4 to organize old photos scattered around my computer. As I do this, I am moving to a standardized naming system. To do that easily requires that I be able to retrieve specific portions of the old file name for use in the new file name.

I have too many photos to retype the names one by one. I have been trying to organize them BEFORE bringing them into LR to get around this, but I've found that except for this, LR is almost essential to organizing them.

I suppose I could go ahead and tag them and do any edits, then write those edits to the metadata, then remove them from the LR catalog, rename them, then import them again, but that seems like a tedious workaround. Is there any possibility of adding such functions to LR rename, or is there something I've missed that will accomplish this easily?

Dale
Photo of Dale Lundy

Dale Lundy

  • 6 Posts
  • 0 Reply Likes

Posted 6 years ago

  • 4
Photo of jdv

jdv, Champion

  • 728 Posts
  • 56 Reply Likes
I suspect you feel strongly about renaming the files, but I'd like to turn the question around.

Why? You can rename on export, so the name you choose has little to do with actual renditions of images. Honestly, why care about the file name, if you can use metadata to slice across the collection.

I'd spend more time making sure the metadata is correct and reasonable, and importing them images into a sensible and simple structure (perhaps based on the date, or a job name, or a "roll" number -- whatever works for you). But the "leaf" name of the file is one of the least important aspects of digital asset management. You are no longer tied to a simple structure directory approach to managing digital assets.
Photo of Dorin Nicolaescu-Musteață

Dorin Nicolaescu-Musteață, Champion

  • 703 Posts
  • 38 Reply Likes
It would be useful for renaming Olympus and Panasonic files that have a "less-standard" naming scheme. Ex.: P0001234, where only the last four digits are the number suffix that gets reset every 10k shutter releases. Currently, Lightroom treats the whole "0001234" as a number suffix.
Photo of john beardsworth

john beardsworth

  • 1042 Posts
  • 241 Reply Likes
Photo of Dale Lundy

Dale Lundy

  • 6 Posts
  • 0 Reply Likes
Actually, unless I’m missing something, you have exactly the same naming limitations on export, which is one why.

Beyond that, in a perfect world, naming limitations might drop a notch in severity to merely being a nuisance. My computer – which has files scattered many places, some duplicates and not all with the same names, along with many scanned images with their limitations – is not a perfect world. Sometimes in determining what’s what, and bringing order out of chaos, tools are indispensable that would otherwise be merely terribly convenient. My vision is that LR could be far more than something merely to manage your files one you get all the metadata for thousands of images in order; it could be something that helps you get it in sensible order in the first place.

Let me turn the question around. Why not? It’s a very easy thing for Adobe to implement. No, it doesn’t replace having your metadata in order, though once your metadata is in order it would still be a useful tool from time to time. Therefore why not?

I’ve only heard three arguments against it. One is that you don’t need it (false). The second is that you might resort to managing your files through filenames rather than through metadata (absurd thought, but if someone were actually to want to do that for who knows what reason, why would the rest of us care?) Third, it’s the least important aspect of DAM management. Granted. However, though my sun visor is far less important than the steering wheel, it wouldn’t have been a valid reason to never put them on cars. In some situations they are very useful.

John, I hope this makes sense. (And, I hope it doesn’t sound argumentative. That’s not the intent.) Dorin’s example is one good one of why. John’s work-around could work, but it doesn’t seem as simple as just using a standard and well-known LEFT() function within the program's file rename.
Photo of john beardsworth

john beardsworth

  • 1042 Posts
  • 241 Reply Likes
The renaming function is quite primitive, and a more glaring omission is the lack of a string replacement feature such as in Bridge's Batch Rename - String Substitution. I don't think I've ever heard anyone ask for Left / Mid / Right functions before, but I'd be surprised if Adobe added them, given LR's mainly for processing camera generated images. And you've no chance of getting them in LR4!

As the files aren't in LR, maybe fix their names outside. If you're on Windows, it's a pretty trivial task for VB.

"Why not?" Lots more important things need doing first.
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes
Photo of Dale Lundy

Dale Lundy

  • 6 Posts
  • 0 Reply Likes
Rob, thanks for mentioning FileRenamer. A search and replacment renamer isn't what I need but it does go a step beyond the very primitive renamer in Lightroom, and I would expect will be useful to a number of people.
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes
Dale,

You said you have a critical need in Lr4...

Via Lua text configuration file, you can get FileRenamer to rename any way you want. I'm not trying to push plugins, nor water down your feature request (I voted for it) - but FileRenamer *can* satisfy your critical need in the mean time (Lr4 will never have the feature you are requesting, although Lr5 might). If you do need a hand configuring custom renaming, I can help.

Hints:
====
BASIC | Lua
--------------
LEFT( filename, 3 ) | filename:sub( 1, 3 )
RIGHT( filename, 3 ) | filename:sub( -3 )
MID( filename, 2, 3 ) | filename:sub( 2, 3 )

Here is the custom rename function I use (taken out of context), just to give you a feel:

-- note: _dateTime, photog, and camera have been pre-computed.
-- this function computes newBase from whatever it wants, in this case
-- it's the aforementioned plus an image number (fileNumStr) that gets computed.

local function rename()
local _newBase

_newBase = string.format( "%04s%02s%02s%s%02s%02s%02s%s",
_dateTime[1], _dateTime[2], _dateTime[3], photog, _dateTime[4], _dateTime[5], _dateTime[6], camera
)

if str:isStartingWith( base, _newBase ) then -- file is already in standard format
fileNumStr = base:sub( -4 ) -- make sure it's the same with an expected file num.
else
computeFileNumStr() -- file-num-str
end

_newBase = _newBase .. fileNumStr

app:log( "New name: ^1", _newBase )

newBase = _newBase
end

It renames file based on photographer, camera designation, capture date/time, and image number.

It obviously requires some programming aptitude to come up with custom renaming functions, but if you know how to program in basic, lua will be a snap...

Rob