Help retaining subfolder structure while renaming

Started by projectSciatic06, April 06, 2024, 12:38:10 PM

Previous topic - Next topic

projectSciatic06

Hi Friends,

My goal is to land files\folders into a 'Queue' folder, and use Exiftools to rename and move them into a 'Renamed' folder, to ensure they are processed only once.

I have a script running hourly. I'm renaming the files to prefix with the DateTaken.   i.e. "IMG_0101.jpg" to "2024-04-06 - IMG_0101.jpg". Additionally I'm coalescing DateTimeOriginal>CreateDate>ModifiedDate should they not exist for whatever reason. 


I setup a "Queue" folder where I can drop files\folders into a "Queue"

My script currently looks like
/volume1/NAS/Trial/PhotoRenamer/Script/ExifTool/exiftool '-FileName<FileModifyDate' '-FileName<CreateDate' '-FileName<DateTimeOriginal' -r -d  %Y-%m-%d' - '%%f.%%e /volume1/NAS/Trial/PhotoRenamer/Queue -directory=/volume1/NAS/Trial/PhotoRenamer/Renamed


My issue is when the files are moved from 'Queue' to 'Renamed', they are losing their subfolder structure and landing in the root of 'Renamed'.

I think the best way to solve this is to use Filepath and replace 'Queue' with 'Renamed' but I'm lost trying to correctly write the arguments.


To recap, trying to move
FROM:  /volume1/NAS/Trial/PhotoRenamer/Queue/f1/f2/IMG_0101.jpg
TO:    /volume1/NAS/Trial/PhotoRenamer/Renamed/f1/f2/2024-04-06 - IMG_0101.jpg
where f1/f2/ do not exist in 'Renamed'

Many thanks for the assist!

I'm running this in Synology DSM and calling exiftools from a bash script

StarGeek

The best thing to do is to use the %d variable as detailed in the -w (-TextOut) option.  Also, it's better to include the directory when writing Filename rather than try to use it separately, as the interactions can be complicated when using both.

First CD into /volume1/NAS/Trial/PhotoRenamer/Queue/

Then, include the target directory path as part of the -d (-dateFormat) option.  Instead of providing the full file path for the source files, you would use a dot . to indicate the current directory.

exiftool '-FileName<FileModifyDate' '-FileName<CreateDate' '-FileName<DateTimeOriginal' -r -d '/volume1/NAS/Trial/PhotoRenamer/Renamed/%%d%Y-%m-%d - %%f.%%e' .

Alternatively, if you don't want to change directories, you can remove the top levels with %d. In your example, you would want to remove the top five levels and use a colon to indicate you are removing directories from the top down instead of bottom up.  This would be %%:5d, with the percent signs % doubled since it's included in the Date Format string (same as the %%f and %%e)

exiftool '-FileName<FileModifyDate' '-FileName<CreateDate' '-FileName<DateTimeOriginal' -r -d '/volume1/NAS/Trial/PhotoRenamer/Renamed/%%:5d%Y-%m-%d - %%f.%%e' /volume1/NAS/Trial/PhotoRenamer/Queue/

Test these out first by using Testname instead of Filename to make sure the results are what you want.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

projectSciatic06

Works like a charm, thanks stargeek for the -v help!