ExifTool > The Image::ExifTool API

using PERL to search and sort multiple fields

(1/3) > >>

hi there, i'm using exiftool and perl to discover files, then look in the 'Instructions' field for data, if its blank i move it to the next location. i'd like to expand that code to look in 2 fields. once i get my filelist i'm looking at each file with 'foreach' and looking at the tag, whats the best method to add 2 fields to look at? i tired
--- Code: ---my @tags = qw(Instructions, SpecialInstruction);
--- End code ---
but foreach seems to look fir the first field, and then move on, then when the next image comes up, it looks in 'specialinstruction' so its only works on every other image.

--- Code: ---foreach $file (@fileslist) {
my @tags = qw(Instructions);
$exifTool->Options(Duplicates => 0);
my $tag_find = $exifTool->ImageInfo($file, \@tags);
foreach (@tags) {
if ("$tag_find->{$_}" eq "")
print "$file in $row needs to go to $daysumanfolder\n";
print FILE"$date\t$time\t$row\t$day\t$file\t$daysumanfolder\n";

$exifTool->SetNewValue(Instructions => "outsourced $date $time");
$exifTool->SetNewValue(Source => "day$day");
$exifTool->SetNewValue(Label => "Second");
$exifTool->WriteInfo( $file) or warn "$!";
print "this is what daysumanfolder is doing $file $daysumanfolder\n";
copy ($file, $forsumanbasefolder) or warn "copy of bad files failed $!";

--- End code ---

my @tags = qw(Instructions SpecialInstruction);

Assuming the rest of the code works.

Although I would think
if (!($tag_find->{$_}))
would be better than
if ("$tag_find->{$_}" eq "")

this still seems to get every other image as it checks the list of files, seems like having 2 fields doesn't work?

--- Code: ---DB-105000320_Black_FT.psd instructions field has data
DB-105000320_DazzlingBlue_BK.psd in /Volumes/photorepos/Partners/Dress_Barn_Online/Post/instock/6 needs to go to /Volumes/photorepos/Partners/OutSource/Outbound/
this is what daysumanfolder is doing DB-105000320_DazzlingBlue_BK.psd /Volumes/photorepos/Partners/OutSource/Outbound/
DB-105000320_DazzlingBlue_BK.psd instructions field has data
DB-105000320_DazzlingBlue_DT.psd in /Volumes/photorepos/Partners/Dress_Barn_Online/Post/instock/6 needs to go to /Volumes/photorepos/Partners/OutSource/Outbound/
this is what daysumanfolder is doing DB-105000320_DazzlingBlue_DT.psd /Volumes/photorepos/Partners/OutSource/Outbound/
DB-105000320_DazzlingBlue_DT.psd instructions field has data
DB-105000320_DazzlingBlue_FT.psd in /Volumes/photorepos/Partners/Dress_Barn_Online/Post/instock/6 needs to go to /Volumes/photorepos/Partners/OutSource/Outbound/
this is what daysumanfolder is doing DB-105000320_DazzlingBlue_FT.psd /Volumes/photorepos/Partners/OutSource/Outbound/
DB-105000320_DazzlingBlue_FT.psd instructions field has data
DB-105000320_ShyBlush_BK.psd in /Volumes/photorepos/Partners/Dress_Barn_Online/Post/instock/6 needs to go to /Volumes/photorepos/Partners/OutSource/Outbound/
this is what daysumanfolder is doing DB-105000320_ShyBlush_BK.psd /Volumes/photorepos/Partners/OutSource/Outbound/
DB-105000320_ShyBlush_BK.psd instructions field has data
DB-105000320_ShyBlush_DT.psd in /Volumes/photorepos/Partners/Dress_Barn_Online/Post/instock/6 needs to go to /Volumes/photorepos/Partners/OutSource/Outbound/
this is what daysumanfolder is doing DB-105000320_ShyBlush_DT.psd /Volumes/photorepos/Partners/OutSource/Outbound/

--- End code ---

Should it be SpecialInstructions rather than SpecialInstruction?

This sample code should check all the psd files in the current directory and displays which of the two tags has content:

--- Code: ---#!/usr/bin/perl

use strict;
use warnings;
use Image::ExifTool;

my @image_files=`ls -1 *.psd`;
foreach my $file (@image_files) {
  my $exifTool = new Image::ExifTool;
  $exifTool->Options(Duplicates => 0);
  my @tags = qw(Instructions SpecialInstructions);
  my $hash_ref = $exifTool->ImageInfo($file, \@tags);
  foreach my $tag (@tags) {
    if (!(my $tag_contents = $hash_ref->{$tag})) {
       printf("%-10s %-10s missing\n",$file,$tag);
    } else {
       printf("%-10s %-10s exists %-10s\n",$file,$tag,$tag_contents);
  print "\n";

--- End code ---

this could be part of it, when i run commands to write data into a file, it doens't seem to work?

--- Code: ---exiftool -overwrite_original_in_place -R -Instructions=TechCloud  -SpecialInstructions=TechCloud
--- End code ---

--- Code: ---exiftool -Instructions -SpecialInstructions /Users/flieckb/Desktop/DB-105000318_Blue_FT.psd
Instructions                    :
Special Instructions            : TechCloud
--- End code ---

but if i open the file in PS, i can see data in that instructions field?

here is the file in question also. https://we.tl/t-xZ3ag1SrkJ


[0] Message Index

[#] Next page

Go to full version