The below is working great (Thanks again Phil)...
https://exiftool.org/forum/index.php/topic,9647.msg50094.html#msg50094 (https://exiftool.org/forum/index.php/topic,9647.msg50094.html#msg50094)
exiftool -config ~/Desktop/my.config -o . -P -m '-directory</home/user/Desktop/DstFolder/${MyDate#;DateFmt("%Y")}/NO_MODEL/${MyDate#;DateFmt("%m")}/$MyDate' '-directory</home/user/Desktop/DstFolder/${MyDate#;DateFmt("%Y")}/${MyDate#;DateFmt("%m")}/${model;tr/ /_/}/$MyDate' -d %Y-%m-%d /home/user/Desktop/SrcFolder/*
Questions;
1. I need to use imagemagick to resize photos based on a width larger than ?, e.g. (-imagewidth > 1024).
I read it isn't possible to use exiftool to output to another program (like imagemagick).
Is it possible to resize with imagemagick, and then have exiftool copy over all metadata programatically
to the result ? e.g. (image01.jpg -> image01.tif <- exiftool copy all original metadata)
The copy metadata function in imagemagick is lacking.
2. In the above code, may I ask for help in how to break apart the long line into a more readable output
suitible for copy and pasting into a bash terminal ? I tried to use \ at the end of lines.
exiftool -config ~/Desktop/my.config -o . -P -m \
'-directory</home/user/Desktop/DstFolder/${MyDate#;DateFmt("%Y")}/NO_MODEL/${MyDate#;DateFmt("%m")}/$MyDate' \
'-directory</home/user/Desktop/DstFolder/${MyDate#;DateFmt("%Y")}/${MyDate#;DateFmt("%m")}/${model;tr/ /_/}/$MyDate' \
-d %Y-%m-%d /home/user/Desktop/SrcFolder/*
3. Where would I use the -if conditions in the above code ?
-if -imagewidth > 1024 (do the copy)
4. Can I substitue the long Source Dir and Destination Dir with bash variables ? e.g. DstFolder="/home/user/Desktop/DstFolder"
Tried: '-directory<$DstFolder/... and '-directory<"$DstFolder"/...
Thank you.
Best regards
Quote from: captured on November 08, 2018, 01:11:06 AM
1. Is it possible to resize with imagemagick, and then have exiftool copy over all metadata programatically
to the result ?
See the Copying Examples in the docs page, specifically example 2 (https://exiftool.org/exiftool_pod.html#exiftool--TagsFromFile-src.jpg--all:all-dst.jpg).
I can't really help with question 2 as I don't use bash
Quote3. Where would I use the -if conditions in the above code ?
For ease of use, you could stick it at the end. But, with only a few limitations, it can go pretty much anywhere. The limitations would be that it can't go before the
-Config option (https://exiftool.org/exiftool_pod.html#config-CFGFILE), which must be the first option if used. And it can't break up an option that requires a second parameter, such as the
-o (outfile) option (https://exiftool.org/exiftool_pod.html#o-OUTFILE-or-FMT--out) or another
-if.
Quote4. Can I substitue the long Source Dir and Destination Dir with bash variables ? e.g. DstFolder="/home/user/Desktop/DstFolder"
Tried: '-directory<$DstFolder/... and '-directory<"$DstFolder"/...
Yes. I'm going from memory here, but I think you're close with the second version. If I'm wrong, someone will correct me, but I think it's something like this:
'-directory<'"$DstFolder"'/...So that's enclose the exiftool part in single quotes (especial around the
< to avoid redirection), then enclose the bash variable with double quotes without a space between the two sections. There's several examples in this forum, such as this post (https://exiftool.org/forum/index.php/topic,7618.msg38641.html#msg38641).
Quote from: captured on November 08, 2018, 01:11:06 AM
2. In the above code, may I ask for help in how to break apart the long line into a more readable output
suitible for copy and pasting into a bash terminal ? I tried to use \ at the end of lines.
What you have done works.
Quote4. Can I substitue the long Source Dir and Destination Dir with bash variables ? e.g. DstFolder="/home/user/Desktop/DstFolder"
Tried: '-directory<$DstFolder/... and '-directory<"$DstFolder"/...
Shell variables are expanded in double-quoted strings. So use double quotes if you want the variables to be expanded by the shell. If you also have ExifTool variables (that shouldn't be expanded by the shell), then you either need to switch to single quotes or escape them within the double quotes.
- Phil
Thank you both Phil and StarGeek for your assistance.
I am experiencing a new puzzle, the code is producing results per your corrections, however all .webp files are not copied.
my.config;
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
MyDate => {
Desire => {
0 => 'DateTimeOriginal',
1 => 'CreateDate',
2 => 'ModifyDate',
3 => 'FileModifyDate',
},
ValueConv => '$val[0] || $val[1] || $val[2] || $val[3]',
PrintConv => '$self->ConvertDateTime($val)',
},
},
);
1; #end
Bash Variables;
Source Directory: SrcDir="/home/user/Desktop/SrcDir"
Destination Directory: DstDir="/home/user/Desktop/DstDir"
exiftool;
exiftool -config my.config -o . -P -m \
'-directory<'"$DstDir"'/${MyDate#;DateFmt("%Y")}/NO_MODEL/${MyDate#;DateFmt("%m")}/$MyDate' \
'-directory<'"$DstDir"'/${MyDate#;DateFmt("%Y")}/${MyDate#;DateFmt("%m")}/${model;tr/ /_/}/$MyDate' \
-d %Y-%m-%d "$SrcDir"
Total Source Files;
find "$SrcDir" -type f -exec file --mime-type --separator=";" '{}' \; | awk '{if ($NF ~ /^image\//) print $NF}' | sort | uniq -c
Result;
636 image/jpeg
5 image/png
1 image/tiff
2 image/vnd.adobe.photoshop
77 image/webp
Total Destination Files After exiftool;
find "$DstDir" -type f -exec file --mime-type --separator=";" '{}' \; | awk '{if ($NF ~ /^image\//) print $NF}' | sort | uniq -c
Result;
634 image/jpeg
5 image/png
1 image/tiff
2 image/vnd.adobe.photoshop
Question;
What did I do wrong, all .webp images did not copy over with exiftool.
Regards.
Quote from: captured on November 09, 2018, 03:10:57 AM
I am experiencing a new puzzle, the code is producing results per your corrections, however all .webp files are not copied.
This is FAQ 16 (https://exiftool.org/faq.html#Q16).
- Phil
OK, thank you Phil, re-reading the FAQ now.
I have an error regarding a read date fail...
not sure if I should start a new thread or not, excuse me if should be starting a new thread.
exiftool -a -G1 -AllDates -d "%Y-%m-%d" Tom_Merrow_14724673.Craterlakewizardisland.jpg
[ExifIFD] Date/Time Original : 20030323 153600
[ExifIFD] Create Date : 20030323 153600
[IFD0] Modify Date : 2003-03-25
I can't get the format to apply -d "%Y-%m-%d" to this one image.
My charset is;
LANG=en_US.UTF-8
GDM_LANG=en_US
LANGUAGE=en_US
What might be causing this.
Is there a method available to verify correct dates for each of the dates in my.config, and if one is not
correct, move to the next correct date, ending with -FileModifyDate if the first 3 fail ?
Thank you.
Sorry, didn't attach the image.
https://imagebin.ca/v/4M6LUS11oiX4
The date/time formatting for CreateDate and DateTimeOriginal is incorrect for this file. To fix it, you can do this:
exiftool -tagsfromfile @ -createdate -datetimeoriginal FILE
There are other problems as well:
> exiftool ~/Desktop/4M6LUS11oiX4.jpg -validate -warning -a
Validate : 8 Warnings (2 minor)
Warning : [minor] Invalid date/time format for EXIF:DateTimeOriginal
Warning : [minor] Invalid date/time format for EXIF:CreateDate
Warning : Non-standard format (rational64u) for ExifIFD 0x9204 ExposureCompensation
Warning : Non-standard format (string) for ExifIFD 0x9286 UserComment
Warning : IFD1:ThumbnailLength is zero
Warning : Missing required JPEG ExifIFD tag 0x9101 ComponentsConfiguration
Warning : Missing required JPEG ExifIFD tag 0xa000 FlashpixVersion
Warning : Missing required JPEG IFD0 tag 0x0213 YCbCrPositionin
- Phil
-verify... A very smart and useful edition Phil.
Is there additional reading other than FAQ #25 for -validate ?
1. time exiftool -all:all -validate -warning -error 4M6LUS11oiX4.jpg
real 0m0.204s
user 0m0.199s
sys 0m0.009s
2. time exiftool -datetimeoriginal -validate -warning -error 4M6LUS11oiX4.jpg
real 0m0.175s
user 0m0.171s
sys 0m0.004s
Questions;
1. If using -validate, does it make exiftool have to read the file twice, once for validation, once for metadata ?
2. Do I have to validate the entire file, can I selectively validate tags, e.g. dates only,
hoping it would save time not reading the entire file ?
3. I moved the problem image in this thread into dir: Testing123 and used this from a post in this forum;
May I please ask for help in the syntax to -validate and display 1 -filename -warning -error per problem file ?
I've tried;
$ exiftool -if "$validate ne 'OK'" -filename -error -warning -a -T Testing123/
$ exiftool -if '$validate ne 'OK'' -filename -error -warning -a -T Testing123/
$ exiftool -if '$validate ne "OK"' -error -warning -a -T Testing123/
$ exiftool -m -q -q -if '($validate ne "OK")' -p '$filename; $validate' Testing123/
$ exiftool -m -q -q -if '($validate ne "OK")' -p '$filename; $warning $error' Testing123/
I'm interested in verifying the date fields only. The example image was the only image that failed
to process from the working code.
Thank you much.
Regards.
Quote from: captured on November 10, 2018, 10:39:54 AM
-verify... A very smart and useful edition Phil.
Is there additional reading other than FAQ #25 for -validate ?
This is one of the Extra tags (https://exiftool.org/TagNames/Extra.html).
QuoteQuestions;
1. If using -validate, does it make exiftool have to read the file twice, once for validation, once for metadata ?
No, the file is just read once. But it will read the entire JPEG to validate the image data.
Quote2. Do I have to validate the entire file, can I selectively validate tags, e.g. dates only,
hoping it would save time not reading the entire file ?
No. Validate is all or nothing.
Quote3. I moved the problem image in this thread into dir: Testing123 and used this from a post in this forum;
May I please ask for help in the syntax to -validate and display 1 -filename -warning -error per problem file ?
Try this:
exiftool -filename -warning -error -api validate DIRQuoteI'm interested in verifying the date fields only. The example image was the only image that failed
to process from the working code.
The above command will just show one warning, which may or may not be from a date field.
- Phil
Many thanks to all.
Best regards.
[Solved]