ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: lumiere on January 02, 2022, 05:08:10 AM

Title: Trying to copy files - it didn't work correctly (wrong destination names)
Post by: lumiere on January 02, 2022, 05:08:10 AM
I was trying to copy files across and used the following command

exiftool  -progress --ext pdf -api QuickTimeUTC '-CreateDate<DateTimeOriginal' '-FileModifyDate<DateTimeOriginal'  '-filename<CreateDate' '-filename<DateTimeOriginal' \
  -d destination/pictures/%Y/%m/%d/%Y-%m-%d_%H:%M:%S%%+c.%%e -r source_dir -efile3 errors.txt -if '$filesize# > 300000' -o

All the files had literally "%Y", "%m", etc in their names instead of numbers. Moving files (without "-o") worked fine whereas copying didn't.
With all those parameters above what is the syntax to copy files ?
Title: Re: Trying to copy files - it didn't work correctly (wrong destination names)
Post by: Phil Harvey on January 02, 2022, 07:07:43 AM
The -o option requires an argument. Just use "." for a dummy argument since you are already setting the output directory.  (ie. use -o .)

- Phil
Title: Re: Trying to copy files - it didn't work correctly (wrong destination names)
Post by: lumiere on January 02, 2022, 11:24:46 AM
Does the position of -o . matter ?
Title: Re: Trying to copy files - it didn't work correctly (wrong destination names)
Post by: StarGeek on January 02, 2022, 12:02:10 PM
No.  You just can't split the two parameters with something else in between.

Position almost never matters in an exiftool command.  There are a few exceptions such as the -Config option (https://exiftool.org/exiftool_pod.html#config-CFGFILE) and the -Common_Args option (https://exiftool.org/exiftool_pod.html#common_args).
Title: Re: Trying to copy files - it didn't work correctly (wrong destination names)
Post by: lumiere on January 02, 2022, 12:07:40 PM
Something is not right:

experiment$ tree -L 1 .
.
├── source
└── destination

2 directories, 0 files

I used the following command

exiftool -o . -progress --ext pdf -api QuickTimeUTC '-CreateDate<DateTimeOriginal' '-FileModifyDate<DateTimeOriginal'  '-filename<CreateDate' '-filename<DateTimeOriginal' -d destination/pictures/%Y/%m/%d/%Y-%m-%d_%H:%M:%S%%+c.%%e -r source -efile3 errors.txt -if '$filesize# > 300000'

And the files are being created also in the top level folder as well:

experiment$ tree -L 1 .
.
├── 04031177.png
├── 139467424.png
├── 140599528.png
├── 140600256.png
├── 140602571.gif
...
├── 193970638.png
├── source
└── destination
└── errors.txt

One of those files in the top level folder has the following exif data:

experiment$ exiftool -time:all -a -G0:1 -s f526646448.jpg
[File:System]   FileModifyDate                  : 2022:01:02 16:52:10+00:00
[File:System]   FileAccessDate                  : 2022:01:02 16:55:42+00:00
[File:System]   FileInodeChangeDate             : 2022:01:02 16:52:10+00:00
[EXIF:IFD0]     ModifyDate                      : 2009:09:15 10:20:55

Why it is not created in the following folder destination/pictures/2009/09/15/...... ?
Title: Re: Trying to copy files - it didn't work correctly (wrong destination names)
Post by: StarGeek on January 02, 2022, 12:19:29 PM
You're only writing Filename when one of two tags exist
'-filename<CreateDate' '-filename<DateTimeOriginal'

Your example PNG doesn't have either of those. When Filename (or Directory) is written, that destination will override the directory specified by the -o (-out) option (https://exiftool.org/exiftool_pod.html#o-OUTFILE-or-FMT--out) (see first paragraph in that link).

You can either set the -o option to be the default location where you want files that don't match either of the above filename commands, or add a default location in front of those

(trailing slash is needed here)
-o /path/to/default/ '-filename<CreateDate' '-filename<DateTimeOriginal'
or
-o . -directory=/path/to/default/ '-filename<CreateDate' '-filename<DateTimeOriginal'
Title: Re: Trying to copy files - it didn't work correctly (wrong destination names)
Post by: lumiere on January 02, 2022, 06:16:41 PM
That makes sense.
Thanks a lot StarGeek  :)