I am using cygwin. What this script does is load the iphone pics that I have loaded into a directory on the desktop. It opens it up in image viewer, to let me take a look at the picture.
system("cygstart $dirname/$oldfile") ;
Then it gives me the option to rename the picture. It is throwing errors though, and not renaming the picture.
Use of uninitialized value $oldfile in concatenation (.) or string at ./rename_image.pl line 29, <STDIN> line 6.
oldfile is a global varaible, the functions should see the variable.
#!/usr/bin/perl
#
use strict ;
use warnings ;
my $oldfile;
my $new_name;
my $dirname = "/cygdrive/c/Users/walt/Desktop/iphonepics/bunk_box/";
opendir(DIR, $dirname) or die "Cannot open dir: $!";
my @files = readdir(DIR);
foreach $oldfile (@files) {
system("cygstart $dirname/$oldfile") ;
print "Do you want to rename $oldfile ? ";
my $input = <STDIN> ;
chomp $input ;
if($input =~ m/^[y]$/i) {
rename_file() ;
} else {
my $doo = 1 ;
}
}
sub rename_file {
use File::Copy qw(move) ;
print "New name:\n" ;
my $new_name = <STDIN> ;
chomp $new_name ;
move "$dirname/$oldfile", "$dirname/$new_name";
return ;
}