# How do I change date folder name format in Lightroom?

I merged two libraries, one uses folders like d:\photos\yyyy\yyyy-mm-dd the other e:\photos\yyyy\mm\dd. I moved all of these to a NAS, but now the structure is inconsistent.

Similar to this question, I would like to change the folder structure for all photos in a library, so that every existing photo in the library is moved to \\nas\photos\yyyy\yyyy-mm\yyyy-mm-dd. I tried re-importing the existing photos which allows moving them into my desired structure, but that deletes all information associated with the old version of the photo. There doesn't seem to be a way to change the structure when importing a library either.

I could just do it by hand, but that's tedious and error-prone... There doesn't seem to be a plugin to do this, and checking out the API reference in the 5.0 SDK it doesn't seem to be possible to move a folder from a plugin like you can manually from the UI(?)

I guess it might be possible to change the structure using SQLite queries (the library is just a database file), but the image files would still need to be moved manually.

Or can I create a new library, import-move the photos to my desired structure and then import my old library, to get my metadata (develop settings, etc) back?

-
What software are you using? You never mention it. – AJ Henderson Oct 10 '13 at 14:07
Lightroom 5.2, sorry, thought the tag would suffice – pascal Oct 10 '13 at 18:03
ah yes, good point. I missed that. Sometimes we have people tag stuff simply because they are using something similar. I assumed Lightroom since the linked question was Lightroom and vs 5 is current though. – AJ Henderson Oct 10 '13 at 18:05

If you are using Lightroom, you need to either move them from within Lightroom (under the Library tab) or do a Find Missing Photos to restore links after moving them.

Depending on what information you need, you could also create side-car files to contain the development settings so that it will import with settings (but not history).

-
But even using "Find missing photos" I would need to select the new location for each folder... – pascal Oct 10 '13 at 18:26
@Pascal - sadly, yes, you would. If that's to labor intensive and you can't do the folder movement itself in Lightroom, sidecars are probably your best bet. – AJ Henderson Oct 10 '13 at 18:40

Here is what I did now:

I created a new empty catalog and imported the images from the old c:\photos\yyyy\mm\dd and d:\pictures\yyyy\mm\dd folder structure into a new \\nas\photos\yyyy\yyyy-mm\yyyy-mm-dd structure.

Then I opened the merged catalog with my metadata, which now indicated all photos missing. I used “Find Missing Folder” on the yyyy root folders which merged the old c: and d: roots, but indicated the mm month folders still missing.

Then I closed Lightroom, opened the .lrcat file in sqlitestudio and ran these queries which rewrite yyyy\mm\dd to yyyy\yyyy-mm\yyyy-mm-dd, and yyyy\yyyy-mm-dd to yyyy\yyyy-mm\yyyy-mm-dd if the yyyy folder is a root.

-- yyyy/mm/dd => yyyy/yyyy-mm/yyyy-mm-dd
replace into aglibraryfolder (id_local, id_global, pathFromRoot, rootFolder)
select aglibraryfolder.id_local, aglibraryfolder.id_global,
name || '-' || substr(pathFromRoot, 1, 2) || '/' || name || '-'
|| substr(pathFromRoot, 1, 2) || '-' || substr(pathFromRoot, 4, 2)
|| '/' as pathFromRoot,
aglibraryfolder.rootFolder
from aglibraryfolder, aglibraryrootfolder
where aglibraryfolder.rootFolder = aglibraryrootfolder.id_local
and cast(name as integer) > 1000 and name glob '????'
and pathFromRoot glob '??/??/' ;

-- yyyy/yyyy-mm-dd => yyyy/yyyy-mm/yyyy-mm-dd
replace into aglibraryfolder (id_local, id_global, pathFromRoot, rootFolder)
select aglibraryfolder.id_local, aglibraryfolder.id_global,
substr(pathFromRoot, 1, 7) || '/' || pathFromRoot as pathFromRoot,
aglibraryfolder.rootFolder
from aglibraryfolder, aglibraryrootfolder
where aglibraryfolder.rootFolder = aglibraryrootfolder.id_local
and pathFromRoot glob '????-??-??/'
and cast(name as integer) > 1000
and name == substr(pathFromRoot, 1, 4) ;


After opening the catalog again everything seems allright, there are some empty month-folders left, they can be deleted.

-