How to Organize/Rename Files in Directory Structure using the Description tag?

Started by yann.boudreau, September 10, 2017, 10:26:08 AM

Previous topic - Next topic

yann.boudreau

Hello,

I would like to automatically create a folder structure and rename my files based on the following format:

Original file:
something.jpg

Desired Output file would follow this directory structure:
YYYY/YYYY-MM_DescriptionTag/YYYY-MM-DD_HHmmSS.jpg

I tried this command which works great but I cannot find a way to name folders using the Description tag without error:

exiftool -P -d %Y/%Y-%m/%Y-%m-%d_%H%M%S.%%e "-filename<datetimeoriginal" .

Any help would be much appreciated!

Many thanks.

StarGeek

Unfortunately, you can't insert a tag into the middle of the -d option.  But as of ver 10.49 there is an option to format the date using the Advanced Formatting Feature.

Try this, but try it out first on a test file or using Testname instead of Filename
exiftool -P "-filename<${datetimeoriginal;DateFmt('%Y/%Y-%m')}_$Description/${datetimeoriginal;DateFmt('%Y-%m-%d_%H%M%S.%%e')}"
* 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).

yann.boudreau

Hi,

I tried the following command to run a test as suggested:

exiftool -P "-testname<${datetimeoriginal;DateFmt('%Y/%Y-%m')}_$Description/${datetimeoriginal;DateFmt('%Y-%m-%d_%H%M%S.%%e')}" .

and got the following return:

-bash: -testname<${datetimeoriginal;DateFmt('%Y/%Y-%m')}_$Description/${datetimeoriginal;DateFmt('%Y-%m-%d_%H%M%S.%%e')}: bad substitution

I am using a Mac.

StarGeek

On Mac/Linux, you need to reverse the double/single quotes.

exiftool -P '-filename<${datetimeoriginal;DateFmt("%Y/%Y-%m")}_$Description/${datetimeoriginal;DateFmt("%Y-%m-%d_%H%M%S.%%e")}'
* 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).

yann.boudreau

Many thanks for the quick answer!

I noticed that the program does not process files that do not have a $description tag assigned.
Is there a way to force this behaviour and follow the same directory structure even when the tag is not assigned?
Do I need to manually assign "" to the $description tag of all my files to ensure they are all processed?

Thank you!

StarGeek

From the docs, note 1 on tags:
"Many tag values may be assigned in a single command. If two assignments affect the same tag, the latter takes precedence "

So if we do a copy without the Description tag followed by one with the tag, for any file that actually has a Description tag, the second assignment will take precedence.  Files without a Description tag won't be affected the the second assignment.  Though it does start to look messy at that point.

exiftool -P '-filename<${datetimeoriginal;DateFmt("%Y/%Y-%m")}/${datetimeoriginal;DateFmt("%Y-%m-%d_%H%M%S.%%e")}' '-filename<${datetimeoriginal;DateFmt("%Y/%Y-%m")}_$Description/${datetimeoriginal;DateFmt("%Y-%m-%d_%H%M%S.%%e")}'

Files without the Description tag will throw a Warning: [minor] Tag 'Description' not defined but that can be ignored.
* 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).

yann.boudreau

Works as a charm!
Many thanks for your prompt and detailed response.

Regards,

Yann.