I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2007-12-19 20:06:40-08 by bv
How to do a compound IF statement

Hi Phil, I am trying to figure out how to do a compound IF statement such as if the DateTimeOriginal and ModifyDate and CreateDate are empty / no value then set DateTimeOriginal to FileModifyDate. I tried all three methods (command line, @Argfile, and .Exiftool_config).

I perfer to use @argfile syntax. I made a Composite TAG in .Exiftool_config which works great when outputting results but fails to work in a IF statement.

In anycase, I do not understand Pearl enough to get things right. Pearl is so cryptic to me and add the complexity of you having a internal pasrer in the exiftool, makes things just a bit more impossible. I do hate having to rely on your expertise. You have no idea how much I appriciate your product and your feedback and assistance.

# ==== ArgFile example #1 ================= -P -DateTimeOriginal<FileModifyDate -CreateDate<FileModifyDate -ModifyDate<FileModifyDate -if ( (not $dateTimeOriginal or $dateTimeOriginal !~ /^[12]/) and (not $ModifyDate or $ModifyDate !~ +/^[12]/) and (not $CreateDate of $CreateDate !~ /^[12]/) )

Here is a .exiftools_config version. It works but I cannot use it in a -if statement in the argfile. So I need to get Argfile example #1 above working.

# ==== ArgFile example #2 ================= -P -DateTimeOriginal<FileModifyDate -CreateDate<FileModifyDate -ModifyDate<FileModifyDate -if isAllDates == 0 # ==Results =================== exiftool -v -@ bv_UseModDate.arg img_0018.JPG Condition: Bareword "isAllDates" not allowed while "strict subs" in use - img_00 18.JPG -------- img_0018.JPG (failed condition) 1 files failed condition # ===================== # === code in .exiftool_config file ================== isDate => { Require => 'DateTimeOriginal', ValueConv => 'not $val or $val !~ /^[12]/ ? 0 : 1;', }, isAllDates => { Require => 'DateTimeOriginal','CreateDate','ModifyDate', ValueConv => 'not $val or $val !~ /^[12]/ ? 0 : 1;', }, # == Test results =================== exiftool -S -alldates -year -isdate -isAllDates *.jpg ======== IMG_0117.JPG DateTimeOriginal: 2005:05:20 00:43:58 CreateDate: : : : : ModifyDate: : : : : Year: 2005 IsDate: 1 IsAllDates: 1 ======== IMG_0118.JPG DateTimeOriginal: : : : : CreateDate: : : : : ModifyDate: : : : : Year: IsDate: 0 IsAllDates: 0 # =====================
Direct Responses: 6731 | Write a response