Thanks for your answer, Phil.
DateTimeOriginal is a string, which can be assigned to a file name. As can any tag, which are all ultimately converted to strings. The -d option just affects how the conversion is done.
Yes, but the string usually contains characters valid only under UNIX. UNIX prohibits only the null character in filenames, since it's the C string terminator. Windows disallows ':', for example, which may occur in time strings. Therefore I think
-d is always required.
ExifTool will never kill a file. It will only delete the file from the memory card if it was successfully copied to the hard disk. So your files would still be there.
I was just experimenting yet. Once I'd understood that it moves files I immediately turned the write lock switch on the SD card on. That
exiftool deletes files on the SD card makes no sense to me.
I try to prevent adding new options because nobody has the time to read through the existing options anyway.
Interesting.
It might be true for quick hacks. But once you discover how powerful and unique
exiftool is you'll have the time...
The precedence rules come in very handy when performing some (admittedly uncommon) operations.
...
exiftool '-directory<lensid' '-filename<Unknown/$focallength/%f.%e' FILE ...
Thanks, I wasn't aware of that. The regular scenario in which
exiftool is used seems to be: go into the image directory, then run
exiftool there to move/rename/retag images. But when source/target directories are on different branches you usually do not want that files are moved.
Unrelated directories occur with the
find utility.
find is UNIX' way of doing directory traversal. It is used quite often, because most UNIX programs simply do not understand directory structures and expect pan-ready filenames.
find can select files subtly by searching the file's name and type, permissions, the directory where files are stored and the file system type. It is perfect for feeding images into
exiftool. I wonder how
find and
exiftool fit together?
For example, one could use
find to preview image files shot in the last 2 days on the big screen of a laptop:
function import_jpegs_shot_recently() {
local indir="$1" previewdir="${2:-$TMPDIR/preview$$}"
echo "The temporary directory is '$previewdir'"
find "$indir" -mtime +2 -type f \( -iname '*.jpg' -o -iname '*.jpeg' \) -print0 | \
xargs -0 \
exiftool -P '-FileName<DateTimeOriginal' \
-o dummy/ \
-d "$previewdir/%m-%d %H.%M/%%f.%%le"
}
The intent is to let
exiftool rename the files by precise shooting time (e.g. day, hour, minute) into a temporary directory. Of course this command is not limited to memory cards; it can shake recently edited files out of NAS directories, or the "My Documents" hairball of files under Windows etc.
If you forget to use the
-o dummy/ idiom, however, some Jpegs disappear from the source directory. Consider RAW+JPEG shooting mode: the RAWs would suddenly become orphans on the card. A
--dry-run option would be handy to develop such a command.
Note that the above function requires GNU
find and
xargs. It is efficient because it will use the maximum number of file-names it can pass to
exiftool in a shell command on this system, so
exiftool is not called for every file. Finally, another advantage is that multiple
exiftools can be called parallely, making use of multicore CPUs. This means
find+xargs+exiftool may process a huge number of files much faster than
exiftool alone. See the
-P switch on the
xargs man-page.
Thanks again, Andreas