Copy link to clipboard
Copied
After I edited and Renamed a few hundred Photos, I deleted the Folders with all the dng's. Now I only have the old Backup with all Photos, but there Names are, as they came from the camera. In Lightroom, I can see, that these original names are still in the Metadata. So shouldn't I be able to relink the Photos based in that name, without loosing the renaming? I really hope so! Is there a way??
This should do the job. Instructions are at the top.
Also save a dummy.dng on your desktop.
...
--[[
Copies DNG into missing file locations
SETUP INSTRUCTIONS
Copy all this quoted text into Notepad or TextEdit and save it as a text file on your desktop and call it "YOURFILENAME.lua".
Now you need to create a scripts folder:
In Lightroom, choose Lightroom > Preferences (Mac OS) or Edit > Preferences (Windows).
Choose the Preset tab and select Show Lightroom Presets folder.
Create a folder in the L
Copy link to clipboard
Copied
First, I should like to point out that what I am about to say is the way I think LR works, but I haven't actually tried it, because I have not ever had this specific problem. (But you can try it and find out if I am right)
You can re-link renamed files, but you have to do the relinking one-by-one, as far as I know there is no automatic way to re-link all of them in one big batch operation (because of the renaming). When you re-link the photos, the name in Lightroom returns to the name of the actual file on your disk, thus your Lightroom files now have the name of the file provided by the camera. Whether or not the information in Lightroom under the "original name" field now shows the rename or the original, I do not know.
Side comment: if you are good at writing SQL code, you can probably write a program that fixes the problem in one big batch operation, but that is beyond my expertise (I write lots of SQL code, so it wouldn't be a difficult piece of code to write if you know SQL, but I have not ever written SQL for Lightroom's database)
Copy link to clipboard
Copied
dj_paige wrote
if you are good at writing SQL code, you can probably write a program that fixes the problem in one big batch operation
A somewhat easier approach might to use SQL to extract the original filename of the photo and its current path into a text file, and then use shell scripting to rename and move the photos into place. That SQL might be easier to write reliably, since it wouldn't have to update the catalog. There have been numerous posts in this forum and the Lightroom SDK forum over the years with fragments of SQL that would get someone experienced with SQL started.
I thought at first a plugin could extract this info, but I quickly verified that the original-filename field isn't available to plugins.
Copy link to clipboard
Copied
If you're reasonably good at scripting, you can exporting photo metadata from the catalog using a plugin, extract the same metadata from the restored files using ExifTool, match them up, and then rename the files in the script. See this thread for more details: Re: Match lost files by meta data
Copy link to clipboard
Copied
Alternatively, you might be able to make DNGs from the files restored from the backup (you would do this in a temporary catalogue). If these files' names match the DNGs you have lost, the process of relinking would be easier. Of course, a lot depends on how you have renamed files.
How thoroughly have you deleted the folders of DNGs. Are they in the trash / recycle bin?
Copy link to clipboard
Copied
Unfortunately not. I don't drop balls, even in making mistakes ;o(
So far, I converted the files to DNG with the Adobe DNG Converter. The Names are still wrong, of course. There is a function in Lightroom to rename to the original filename. That would have made the relink smooth, but ironically, that only works, if the linked files are NOT missing ... (btw I don't understand that....)
I don't have to solve it today, so I hope for the geniuses answer )
Copy link to clipboard
Copied
"I converted the files to DNG with the Adobe DNG Converter"
OK, what I am thinking is that you could import these DNG files into a temporary LR catalogue and rename them using the same renaming method that you used before. Would the filenames now correspond exactly to the filenames in the main catalogue?
Copy link to clipboard
Copied
This is a great Idea. But it reminds me of one thing, I didn't mention: This Backup was BEFORE I made the selection. So, I would have to make the selection from scratch and be right about every picture ... Right?
Copy link to clipboard
Copied
I don't quite understand you. What do you mean by "made the selection"? Do you mean you deleted files, then did the renaming? So for example, we cannot be sure that (say) the "new" DNG #100 is the same photograph as "missing" DNG #100, because the renaming was after deleting reject photos?
Copy link to clipboard
Copied
Exactly 🙂
Copy link to clipboard
Copied
How simple was your renaming scheme?
I am thinking aloud here. If it was something like YYMMDD Hannover SEQ#.dng, in Explorer/Finder we could create a folder to replace the one that is now missing and put in it "dummy" DNGs with the filenames YYMMDD Hannover SEQ#.dng. So we fool LR into thinking that the files are no longer missing, and we can then rename them back to the original names. That done, we throw away the dummy DNGs and put the restored original-filename DNGs into the folder. And that may be it.
If this does make sense, backup your catalogue before trying it. Paige, or anyone, what do you think?
Copy link to clipboard
Copied
As I never rename files, all this is speculation on my part ... about possible Lightrooom behavior in situations I have never been in ... it sounds like it might work, except for the part where you "rename them back to the original names". Is that a LR function that I don't know about? How would you do that?
Copy link to clipboard
Copied
It's in the standard renaming dialog - Filename Template Editor.
John
I
Copy link to clipboard
Copied
If that could work... But I guess, the Problem would be, that my renaming was not straight and simple. So it would probably about the same work making those files, as just relink the Photo files One by One and than rename them.
Copy link to clipboard
Copied
Generating the dummy DNGs could be done automatically with a script. It would just loop through missing files and create a DNG with that filename.
Copy link to clipboard
Copied
This should do the job. Instructions are at the top.
Also save a dummy.dng on your desktop.
--[[
Copies DNG into missing file locations
SETUP INSTRUCTIONS
Copy all this quoted text into Notepad or TextEdit and save it as a text file on your desktop and call it "YOURFILENAME.lua".
Now you need to create a scripts folder:
In Lightroom, choose Lightroom > Preferences (Mac OS) or Edit > Preferences (Windows).
Choose the Preset tab and select Show Lightroom Presets folder.
Create a folder in the Lightroom folder called Scripts.
Copy the "YOURFILENAME.lua" script into the Scripts folder.
Quit and reopen Lightroom.
You should now see a little scripts menu to the right of the Help menu. It has a single item YOURFILENAME.
--]]
------------------------------DON'T CHANGE BELOW
local LrPathUtils = import 'LrPathUtils'
local LrFileUtils = import 'LrFileUtils'
local LrTasks = import 'LrTasks'
local LrDialogs = import 'LrDialogs'
local SEP
if MAC_ENV then SEP = '/' else SEP = '\\' end
LrTasks.startAsyncTask( function()
srcPath = LrPathUtils.getStandardFilePath( 'desktop' ) .. SEP .. "dummy.dng"
if LrFileUtils.exists( srcPath ) ~= "file" then
LrDialogs.message("Create a dng called dummy.dng and put it on your desktop", srcPath)
return false
end
local catalog = import "LrApplication".activeCatalog()
photos = catalog:getTargetPhotos()
filePaths = {}
for i, photo in ipairs(photos ) do
if photo:checkPhotoAvailability() == false then
destPath = photo:getRawMetadata('path')
LrFileUtils.copy( srcPath, destPath )
end
end
LrDialogs.showBezel("Finished", 5)
end)
Copy link to clipboard
Copied
Wow, Thx. I will try that, and get back to report 🙂
Copy link to clipboard
Copied
Hi John,
worked like a charm, your script!! I screwed up a little - forgot that I already had put the dng's from the backup in the right folder. Then the finder had no chance, but to ad a "-2" to every dummy-dng. But that Name was also put in the Lightroom "Files". So, no big Deal at all. Then I made sure, everything was in place by "Searching for missing Photos".
Then, I renamed them the way, I did before, AND checked with the names of the JPG's i had Exported for the Client (luckily BEFORE all the mess).
Everything was alright!! Phu that was a ride!
Thank you John, Thanks to all of you guys - if you are ever in Hamburg (now VERRY G20-famous) stop by my Studio for a cup of the best Espresso!!!
Copy link to clipboard
Copied
Great. Yours was a problem that I have often wondered about, because I've never figured out a solution before now As John Ellis mentioned, it's impossible to access the Original Filename from a plugin which would be able to go looking for the backup copies. This method involves a bit of manual work, but I'm glad you could follow the idea.
I have high standards when it comes to coffee
Copy link to clipboard
Copied
Challenge Excepted! Your standards shall be raised 😉