Page 1 of 1

Photo renaming and moving into named folders.

Posted: 10 Mar 2023, 02:17
by ArcherCC
Hi all!

I am currently using

Code: Select all

{ dt.format('yyyy-MM-dd HH∶mm∶ss') } [{ camera.model }]
to rename photos.

Is it possible to add to that to make it take all photos from X year create a folder titled "X Year" with folders inside for the months and move the photos into the correct folders it has created or have previously been created?

Thanks.

Re: Photo renaming and moving into named folders.

Posted: 10 Mar 2023, 02:24
by rednoah
Yes, your custom format can generate a file path (and not just the file name) to move files accordingly.

e.g. move absolutely:

Code: Select all

X:/Photos By Year/{ dt.format('yyyy') }/{ dt.format('yyyy-MM-dd HH∶mm∶ss') } [{ camera.model }]
e.g. move relatively to the current file path:

Code: Select all

{folder}/{ dt.format('yyyy') }/{ dt.format('yyyy-MM-dd HH∶mm∶ss') } [{ camera.model }]

Re: Photo renaming and moving into named folders.

Posted: 10 Mar 2023, 02:31
by ArcherCC
OK let me see if I got this correct.

Code: Select all

/D:/Photography Main Folder/Photos By Year/{ dt.format('yyyy') } Year/ Month/ [dt.format('MM') } Month / { dt.format('yyyy-MM-dd HH∶mm∶ss') } [{ camera.model }]
So it would be D:/ Photography Main Folder / 2000 / June / Files ?

Re: Photo renaming and moving into named folders.

Posted: 10 Mar 2023, 02:40
by rednoah
D:/ and not /D:/ but yes. The right-hand side will preview the exact target file path, and then files will be moved/renamed accordingly when you hit the Rename button.

Re: Photo renaming and moving into named folders.

Posted: 10 Mar 2023, 02:50
by ArcherCC
Edit: Hmm when I try to save the code it pops "SyntaxError: unexpected token: ) "

Also, is there a way to add a (1) or something after the filename if they are duplicates? I am working on literally 10s of thousands of folders from years of computers and I know I have some duplicates in there.

Re: Photo renaming and moving into named folders.

Posted: 10 Mar 2023, 07:44
by rednoah
1.
Start with my working code, and then make changes step by step:

Code: Select all

X:/Photos By Year/{ dt.format('yyyy') }/{ dt.format('yyyy-MM-dd HH∶mm∶ss') } [{ camera.model }]
:idea: If you accidentally write bad code, then can always narrow down the problem by deleting your code until it starts working again. You'll find the mistake easily most of the time. If not, narrow it down to the problematic section and paste it here.



2.
You can add {fn} to your format to keep the original file name (which presumably is unique) as well. Alternatively, you can use {i} to refer to the row number.

:!: Duplicate detection and special handling is difficult but possible via the {model} binding. The {di} index binding likely does not work for Photo / File type objects, since each file path is always unique by nature.