Error opening file

Started by JeanR, April 29, 2024, 11:57:01 AM

Previous topic - Next topic

JeanR

Hello,
I am newbie, searched through internet and didn't find solution. Can you help me ? I wrote this very light perl script :

#!/usr/local/bin/perl
use strict;
use Image::ExifTool;

my $exifTool = new Image::ExifTool;
my $dir="/home/jean/Téléchargements/Photos"; my $file;
foreach $path (@INC) { print "$path\n"; }
print "***\n";

my @ls=`ls $dir/*jpg`;
print "@ls \n";
foreach $file (@ls) {
    $meta = $exifTool->ImageInfo("$file"); print "\n***\n";

    foreach (keys %$meta) {
        print "* $_ => $$meta{$_}\n";
    }
}

**** Here is the result :

jean@jebede:~/Téléchargements/Photos$ perl jbexif.perl
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.36.0
/usr/local/share/perl/5.36.0
/usr/lib/x86_64-linux-gnu/perl5/5.36
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl-base
/usr/lib/x86_64-linux-gnu/perl/5.36
/usr/share/perl/5.36
/usr/local/lib/site_perl
***
/home/jean/Téléchargements/Photos/f767781824.jpg
/home/jean/Téléchargements/Photos/f803337856.jpg
/home/jean/Téléchargements/Photos/f803498880.jpg


***
* Directory => /home/jean/Téléchargements/Photos
* Error => Error opening file
* ExifToolVersion => 12.57
* FileName => f767781824.jpg


***
* Directory => /home/jean/Téléchargements/Photos
* Error => Error opening file
* ExifToolVersion => 12.57
* FileName => f803337856.jpg


***
* ExifToolVersion => 12.57
* FileName => f803498880.jpg

* Error => Error opening file
* Directory => /home/jean/Téléchargements/Photos


**
**** Comments
**

With exiftool as bash shell command, I get a good result for these 3 photos, but the perl script cannot open the files and I don't understand why. I need the script working to change a lot of photos. I checked different things : directory and files permissions, paths to ExifTool.pm, renaming directory without french stressed characters...??? Thanks for any help !

Jean




Phil Harvey

Add this line as the first line in your loop to remove the trailing newline on the file name:

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

JeanR

Thanks you a lot Phil ! It works...