Renaming files with xmp

Started by Carlos_Brutus, January 02, 2024, 09:22:58 AM

Previous topic - Next topic

Carlos_Brutus

Greetings everyone,

I've encountered a challenge in renaming a batch of NEF files and their corresponding XMP files. While I've managed to rename the NEF files successfully, the XMP files, which contain processing settings, remain unchanged.

It's important to note that these XMP files have been partially processed in Lightroom, and I'm reluctant to lose the processing settings. However, even after renaming the NEF files using Exiftool with a command like:

exiftool '-filename<${Model;s/NIKON //}_${ShutterCount;$_ = sprintf("%07d", $_)}.%e' -o k2 .

The command works well for the NEF files but doesn't update the associated XMP files or modify a tag inside the XMP files to align with the new NEF filenames.

I'm seeking guidance on how to effectively rename the associated XMP files while ensuring the preservation of the processing settings. Any suggestions or insights on how to achieve this would be greatly appreciated.

Thank you in advance for your help and support!

Carlos


Phil Harvey

Hi Carlos,

So the XMP files don't contain Model and ShutterCount tags?  In this case, you could do the renaming like this (assuming upper-case .NEF extension):

exiftool -tagsfromfile %d%f.NEF '-filename<${Model;s/NIKON //}_${ShutterCount;$_ = sprintf("%07d", $_)}.%e' -ext jpg -ext xmp -fileorder -fileextension -o k2 .

The -fileOrder -fileextension is necessary to be sure the .xmp files are processed first so the .NEF files will be available then.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Carlos_Brutus

Hello Phil,
It looks like the command didn't produce the expected outcome:
Only XMP files were created, without the corresponding raw files with the new names.
I'm currently in the process of recovering and checking duplicates for over 200k photos following a NAS failure.
The filenames are varied, and I'm attempting to standardize them for duplicate detection. Some photos have accompanying XMP files that retain the original filenames and current names (modified by Lightroom), which I need to keep together.
Inside the XMP files, I've found entries like xmpMM:PreservedFileName="810_21209.NEF" and crs:RawFileName="810_21209.NEF".
    After recovery, the files have changed names like f1639880.nef, sometimes with accompanying XMP files and sometimes not.
I'm working on a live Lightroom catalog but planning to move these files securely to another working directory to standardize their names.
Do you have a clear picture of what I'm attempting to achieve? Your assistance is greatly appreciated!

Carlos



Phil Harvey

Darn.  Typo.  It should be -ext nef -ext xmp

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Carlos_Brutus

Thank you Phil for now, testing, playing and enjoying Exiftool more than ever ;)