ExifTool Forum

ExifTool => Newbies => Topic started by: TooManyPictures on March 02, 2018, 01:02:06 PM

Title: sorting/renaming files into ./datetimeoriginal_model/
Post by: TooManyPictures on March 02, 2018, 01:02:06 PM
First of all ' Thank you for writing 'ExifTool' ..

Creating a directory containing the date or model on it's own (exiftool.exe "-Directory<DateTimeOriginal" -d %%Y_%%m_%%d__%%a  .) is straight forward.
For example
./2015-07-07/
or
./GT-I9300/

But combining these two values is where my problem is.

So what I want to create is:
./2015-07-07_GT-I9300/


Any help appreciated ... (I'm running this on windows cmd)
Title: Re: sorting/renaming files into ./datetimeoriginal_model/
Post by: StarGeek on March 02, 2018, 03:05:12 PM

Try
"-Directory<${DateTimeOriginal}_${Model;}"

Since you're adding additional characters to the whole thing, you have to use the dollar sign in front of DateTimeOriginal as well as add the braces to delimit the tag name (as DateTimeOriginal_ could be created as a tag name or a variable used in advanced formatting).  Model will also need the dollar sign.  It could be used without the braces (like ${DateTimeOriginal}_$Model) but Model names often have characters that could be disruptive, such as slashes, which would end up creating a subdirectory.  When you add the braces and then the single semicolon, that will remove such characters.
Title: Re: sorting/renaming files into ./datetimeoriginal_model/
Post by: TooManyPictures on March 03, 2018, 05:46:30 AM
Hello,

Thank you for the help.. I think I tried that before by using:

exiftool.exe  "-Directory<${DateTimeOriginal}_${Model;}" -d %%Y_%%m_%%d__%%a  .

But it created directories like:Y_%m_ and __%a_GT-I9300

So now with your help I came to:

exiftool.exe  "-Directory<${DateTimeOriginal}_${Model;}" -d %Y_%m_%d__%a  .


and that actually worked and created:

./2015_07_07__Tue_GT-I9300

What does the semicolon after Model do?


Title: Re: sorting/renaming files into ./datetimeoriginal_model/
Post by: StarGeek on March 03, 2018, 01:33:38 PM
Quote from: TooManyPictures on March 03, 2018, 05:46:30 AM
Thank you for the help.. I think I tried that before by using:

exiftool.exe  "-Directory<${DateTimeOriginal}_${Model;}" -d %%Y_%%m_%%d__%%a  .

You only need to double percent signs when using a windows batch file or when using a file name format replacement (%f, %d, %e) in the date format string.

QuoteWhat does the semicolon after Model do?

Quote from: StarGeek on March 02, 2018, 03:05:12 PM...but Model names often have characters that could be disruptive, such as slashes, which would end up creating a subdirectory.  When you add the braces and then the single semicolon, that will remove such characters.

For more details, see the second paragraph of docs on Advanced formatting feature (https://exiftool.org/exiftool_pod.html#Advanced-formatting-feature).
Title: Re: sorting/renaming files into ./datetimeoriginal_model/
Post by: TooManyPictures on March 04, 2018, 05:33:40 PM
Hahah .. yes, thank you.. I figured that eventually out.
I did all my testing on the command line, and when I used the same expression in a .cmd it wouldn't work.

Oh dear!

One other thing I found is that when you use  -Directory<${DateTimeOriginal}_${Model;}
Exiftool insists that DateTimeOriginal and Model exists in the exif-tag. If it can't find both tags it throws an error.
But that's no problem, just something I noticed
Title: Re: sorting/renaming files into ./datetimeoriginal_model/
Post by: StarGeek on March 04, 2018, 06:08:40 PM
Quote from: TooManyPictures on March 04, 2018, 05:33:40 PMI did all my testing on the command line, and when I used the same expression in a .cmd it wouldn't work.

I'm not trying to be an ass, but...
Quote from: StarGeek on March 02, 2018, 03:05:12 PMTroubleshooting hints:
...
* Double all percent signs (%) in a Windows batch file.

QuoteOne other thing I found is that when you use  -Directory<${DateTimeOriginal}_${Model;}
Exiftool insists that DateTimeOriginal and Model exists in the exif-tag. If it can't find both tags it throws an error.

See this recent thread (https://exiftool.org/forum/index.php/topic,8980.0.html) for some tips on how to deal with it.  While the thread talks about renaming video files, the examples of renaming depending upon available tags are relevant.