rename file by using date/time/maker/model/directory information

Started by djtn, June 01, 2013, 09:45:34 AM

Previous topic - Next topic

ryerman

Quote from: djtn on June 03, 2013, 03:30:37 PM
The '.' stands for current directory in terms of DOS/Windows Filesystem terminology. So, when running exiftool from the same directory where my single test image file resides in, exiftools returns '.' instead of the name of the directory the file is in.

c:\Program Files (x86)\Bildbearbeitung>exiftool -"Filename<${DateTimeOriginal}_${directory;s/.+\///}_${Make}_${Model}.jpg" -d %Y%m%d_%H%M%S%%-c 1.jpg"
returns 20121208_183347_._SAMSUNG_GT-N7000

When specifying the full path to the test file the problem disappears and returns the correct name of the directory the file is stored into:
20121208_183347_bildbearbeitung_SAMSUNG_GT-N7000.jpg

Quote from: Phil Harvey on June 03, 2013, 06:30:37 PM
.....This is what I suspected, and was trying to communicate...

- Phil

Hi Phil

Sorry, but your reply seems ambiguous.

Is this the desired way for Exiftool to handle this situation?
Leaving the dot (".") "as is" is counter-intuitive to me.

Could Exiftool have expanded the dot to the actual directory name for the output but you coded it otherwise?

I assume that the dot is only a convenient short-cut.
Shouldn't a smart "robot" like Exiftool translate it for us lazy human users? ;)

Jim
Windows 10 Home 64 bit, Exiftool v12.61

Phil Harvey

Hi Jim,

ExifTool receives file/directory names from the command line, and simply reports the directories specified.  This leaves the formatting of the directory name entirely up to you.  I don't want to change "." to an absolute directory name because this would remove the possibility of using relative paths for those people that want this.

If you want absolute paths when running ExifTool in the current directory, on Mac/Linux you can do this:

exiftool `pwd`

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ryerman

Hi Phil
I had assumed that -directory would always return the absolute path, no matter how files and directories were specified on the command line.
Like this (fake output, for example only):
F:\1Hold\Test Exiftool>exiftool -p $directory -ext jpg -r .
F:/1Hold/Test Exiftool
F:/1Hold/Test Exiftool/Second Folder/Another Folder
F:/1Hold/Test Exiftool/Second Folder
    3 directories scanned
    3 image files read


Now I know that "." is not merely a command line short-form, but also affects the output format for -directory.
If Windows users want the output for -directory to be the absolute path, they must use an absolute path for files and/or directories on the command line.

Thanks,

Jim
Windows 10 Home 64 bit, Exiftool v12.61

Phil Harvey

Hi Jim,

Correct.  I can see why the Notes for Directory in the tag name documentation might be ambiguous:

(the directory of the file as specified in the call to ExifTool, or "." if no directory was specified. May be written to move the file to another directory that will be created if doesn't already exist)

But by "as specified", I meant "the same way that you typed it".

And "." isn't really a short form.  It is the actual name of the current directory, and hence also the relative path to the current directory.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).