Moving pictures to dated folders

Started by icexif, November 23, 2014, 03:25:16 PM

Previous topic - Next topic

icexif

I am copying the images to their respective folders based on the dates. It normally works. But for some files, it cannot find the related Tag information, and reasonably fails with throwing an error and copying the image in the same folder of the script.

${EXIF} -o . '-Directory<DateTimeOriginal' -d $TARGETDIR/%Y/%m_%B/%Y.%m.%d -r $SOURCEDIR

I wonder whether there is a fail over mechanism for this, e.g. copy image to FileDate folder if DateTimeOriginal is not available, or copy image to Warning folder etc.

And also what is '-Directory<DateTimeOriginal' part, is it something specific for ExifTool or generic bash ? Where can I find more information about it?

Phil Harvey

Yes.  This is a common question.  Generally, what is done is to fall back to FileModifyDate if no other date/time values exist:

${EXIF} -o . '-Directory<FileModifyDate' '-Directory<DateTimeOriginal' -d $TARGETDIR/%Y/%m_%B/%Y.%m.%d -r $SOURCEDIR

You can copy from as many date/time tags as you want, and the last valid one will override earlier values on the command line.

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

q159866

Hi Phil,

your answer is very valueable because it shows a way to react on a undefined DateTime-Tags.

I want to use exiftool in a autoit-script for copying jpg-files in a date-directory with something like this:

"-filename<CreateDate" -d %Y_%m_%d/jpg/%%f.%%e

This works fine. But now I got 3GP-Files (movies from a android phone) and these files does not own a valid CreateDate-tag. So I use something like this:

"-filename<FileModifyDate" -d %Y_%m_%d/jpg/%%f.%%e

So I think I can do the following, regardless of the filetype?

"-filename<FileModifyDate" "-filename<CreateDate" -d %Y_%m_%d/jpg/%%f.%%e

BUT:
If I use the CreateDate-Tag the files are copied and if I use the FileModifyDate-Tag the files are moved!
Do I something wrong? How can I copy the files if these do not have a valid CreateDate-Tag?

-Robert

Phil Harvey

Hi Robert,

The files should always be moved if you are just writing FileName without the -o option, so I don't understand your statement.  But if you also write another "real" tag, then the files will be copied.

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

Oskar

Hello!

No matter what I do, the following command

exiftool.pl -o . '-Directory<DateTimeOriginal' -d c:\temp\new\%Y\%m_%B\%Y.%m.%d -r c:\temp\Test\


returns me "The system could not find the file specified." Why? Could you help me?

Where new is the destination folder and Test is the folder containing the files to be moved.

I am on Windows 1o 64bit, using Strawberry Perl 5, version 30, subversion 2.

StarGeek

Assuming Windows CMD, use double quotes instead of single quotes.
* 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).

Oskar

Oh, it worked! Double quotes around '-Directory<DateTimeOriginal' - I was trying only around the folders. It works now, thank you very much!

Birdman

Hello there,

I tried to adapt the above mentioned code to use it in a Win 10 CMD-File in order to copy my pictures to a specific directory and sort it there in subdirectories according to yearand month:
exiftool -o . "-Directory<DateTimeOriginal" -d %%Y-%%m "d:\Bilder\NEU\0_Canon EOS M50\%Y\%m_%B\%Y.%m.%d" -r d:\Bilder\NEU\exiftool\test\*.jpg
The subdirectories are created alright, but not as subdirectories in the above specified path (d:\Bilder\Neu\0_Canon EOS M50) but under the exiftool/cmd-path.
There are also the following warnings:
Error opening file - d:/Bilder/NEU/0_Canon EOS M50/m_Y.d
Error: Error opening file - d:/Bilder/NEU/0_Canon EOS M50/m_Y.d

How should I modify the code? I already tried different ways, but no luck.

Martin
Best regards,

Martin (Birdman)

StarGeek

Not an exiftool problem, a Windows problem.  See FAQ #27.
* 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).

Birdman

Quote from: StarGeek on January 04, 2021, 10:36:59 AM
Not an exiftool problem, a Windows problem.  See FAQ #27.
Thanks for your hint. I tried doubling the %-signs before with the same result. In the meantime I tried a shorter code, which works without any error messages, but still creates the subdirectories under the cmd-path:
exiftool -o . "-Directory<DateTimeOriginal" -d %%Y-%%m -r d:\Bilder\NEU\exiftool\test\*.jpg
I just would need to know how to tell exiftool the path under which the new folders should be placed. Or isn't this possible?
Best regards,

Martin (Birdman)

StarGeek

Quote from: Birdman on January 04, 2021, 10:46:02 AM
I just would need to know how to tell exiftool the path under which the new folders should be placed. Or isn't this possible?

Just add the path you want.  You can use the %d token to indicate the file's current directory
exiftool -o . "-Directory<DateTimeOriginal" -d %%%%d/%%Y-%%m -r d:\Bilder\NEU\exiftool\test\*.jpg
or
exiftool -o . "-Directory<%%d/$DateTimeOriginal" -d %%Y-%%m -r d:\Bilder\NEU\exiftool\test\*.jpg

Or use a full path to different location
exiftool -o . "-Directory<DateTimeOriginal" -d "/path/to/directory/%%Y-%%m" -r d:\Bilder\NEU\exiftool\test\*.jpg
or
exiftool -o . "-Directory</path/to/directory/$DateTimeOriginal" -d %%Y-%%m -r d:\Bilder\NEU\exiftool\test\*.jpg

If the %d token (see -w (textout) option for details on filename % codes) is part of the date format string, the percent signs need to be doubled again (see -d (dateFormat) option).

If anything is added before the DateTimeOriginal, then a dollar sign needs to be added to DateTimeOriginal.
* 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).

Birdman

#11
Thanks again, with your advice I managed my problem now. The following code does the trick:
exiftool -o . "-Directory<d:/Bilder/NEU/0_Canon EOS M50/${DateTimeOriginal}" -d %%Y-%%m d:\Bilder\NEU\exiftool\test\*.jpg

Works fine and just what I was looking for. Thanks a lot!
Best regards,

Martin (Birdman)