N
news2003
I have a basic question. It has to do with the way I pass files with
spaces. I have two versions of the same code. once calls $exifTool-
perl extract.pl /home/john/pictures 2/15.jpg
with the code like:
my $file = $ARGV[0];
# Create a new Image::ExifTool object
my $exifTool = new Image::ExifTool;
# Extract meta information from image
$exifTool->ExtractInfo($file);
The second version is taking the code from a file
perl extract2.pl fdir.output.txt
being the code in this case:
open( FILE, "< $filename" ) or die "Can't open $filename : $!";
foreach my $line ( <FILE> ) {
chomp ($line);
print $line."\t";
extractInfo("$line");
}
close FILE;
# read information on files
sub extractInfo(){
my $file = "@_";
# Create a new Image::ExifTool object
my $exifTool = new Image::ExifTool;
# Extract meta information from image
#$exifTool->ExtractInfo($file);
the input file on the second case is like this
/home/john/pictures/49.jpg
/home/john/pictures 2/15.jpg
The first file works fine but the second fails, I reckon is due to the
spacein the name. It seems that when I call the script with the file
name as argument works fine (independently of the presence of the
space) but when I try to back the process using a file with the file
location the process fails if the file name contains spaces on the
path. My Linux box parse the file fine but not when it comes directly
from the file. I have tried to escape the space with \ but get the
same result.
Any ideas?
Thanks in advance for your help
John
spaces. I have two versions of the same code. once calls $exifTool-
ExtractInfo($file) directly as argument from the command line.
perl extract.pl /home/john/pictures 2/15.jpg
with the code like:
my $file = $ARGV[0];
# Create a new Image::ExifTool object
my $exifTool = new Image::ExifTool;
# Extract meta information from image
$exifTool->ExtractInfo($file);
The second version is taking the code from a file
perl extract2.pl fdir.output.txt
being the code in this case:
open( FILE, "< $filename" ) or die "Can't open $filename : $!";
foreach my $line ( <FILE> ) {
chomp ($line);
print $line."\t";
extractInfo("$line");
}
close FILE;
# read information on files
sub extractInfo(){
my $file = "@_";
# Create a new Image::ExifTool object
my $exifTool = new Image::ExifTool;
# Extract meta information from image
#$exifTool->ExtractInfo($file);
the input file on the second case is like this
/home/john/pictures/49.jpg
/home/john/pictures 2/15.jpg
The first file works fine but the second fails, I reckon is due to the
spacein the name. It seems that when I call the script with the file
name as argument works fine (independently of the presence of the
space) but when I try to back the process using a file with the file
location the process fails if the file name contains spaces on the
path. My Linux box parse the file fine but not when it comes directly
from the file. I have tried to escape the space with \ but get the
same result.
Any ideas?
Thanks in advance for your help
John