ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: andysoft on November 14, 2022, 09:32:02 AM

Title: Windows version DIR creation option fails if the exiftool.exe
Post by: andysoft on November 14, 2022, 09:32:02 AM
Hi
I just installed the exiftool.exe into the Windows/System32 directory to access it from any command line and tried to use it in any directory, the tool works fine, but when it comes to specifying to create a directory and move the files, it fails, just because the failed directory is the .exe running one and not the command line directory

I can help, it's easy to fix this, Are there Sources of the windows Files to Contribute?
BTW: The command is just like the example on the website:

exiftool -d %Y-%m-%d "-directory<datetimeoriginal" image.jpg

Title: Re: Windows version DIR creation option fails if the exiftool.exe
Post by: Phil Harvey on November 15, 2022, 08:42:21 AM
The directory should be created in the current working directory.  If you "cd" to Windows/System32 then it would be in there, which you don't want.  You can either "cd" to where you want the directory to be created before running exiftool, or add the target directory to the command, eg)

exiftool -d %Y-%m-%d "-directory<c:/some/directory/name/${datetimeoriginal}" image.jpg

- Phil
Title: Re: Windows version DIR creation option fails if the exiftool.exe
Post by: StarGeek on November 15, 2022, 11:31:36 AM
Quote from: andysoft on November 14, 2022, 09:32:02 AMBTW: The command is just like the example on the website:

exiftool -d %Y-%m-%d "-directory<datetimeoriginal" image.jpg

This command indicates that image.jpg is in the current directory, which is unlikely if you're currently in the system directory.

Phil gives the example of setting the path directly, but if you're providing a more complete path to the file, say C:\Users\User\Pictures\image.jpg, and you want it to be based off of that directory, then you probably want to add the %d variable (see -w (-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut)) to the command.

When included in the date format string, the % needs to be doubled to differentiate it from the %d that stands for the date
exiftool -d %%d%Y-%m-%d "-directory<datetimeoriginal" image.jpg

or it can be moved to the tag copy operand, which means the tag needs a $ prefix since the operation is now mixing a static string with a tag name
exiftool -d %Y-%m-%d "-directory<%d$datetimeoriginal" image.jpg

Also see Writing "FileName" and "Directory" tags (https://exiftool.org/filename.html).
Title: Re: Windows version DIR creation option fails if the exiftool.exe
Post by: andysoft on November 19, 2022, 10:25:38 AM
Thank you for the explanation,
From now on, I'll use those "complicated by useful" syntax-concept (distributed on many help-aka, sections)
 ;D