Photo renaming and moving into named folders.

Any questions? Need some help?
Post Reply
ArcherCC
Posts: 3
Joined: 10 Mar 2023, 02:11

Photo renaming and moving into named folders.

Post 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.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Photo renaming and moving into named folders.

Post 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 }]
:idea: Please read the FAQ and How to Request Help.
ArcherCC
Posts: 3
Joined: 10 Mar 2023, 02:11

Re: Photo renaming and moving into named folders.

Post 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 ?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Photo renaming and moving into named folders.

Post 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.
:idea: Please read the FAQ and How to Request Help.
ArcherCC
Posts: 3
Joined: 10 Mar 2023, 02:11

Re: Photo renaming and moving into named folders.

Post 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.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Photo renaming and moving into named folders.

Post 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.
:idea: Please read the FAQ and How to Request Help.
Post Reply