Hi:
I'm reading a text file which has 2 fields, the existing graphic name, and the corresponding new name. I want to use this file to compare each graphic in a directory and write the newly named graphic to a different directory.
I've gotten up to reading and comparing the text file, but I can't seem write the newly named graphic to a different directory.
Here's what I have so far:
my $dirname_new= "//xyz/Site_graphics/ICS/ICS_new";
opendir(DIR, "$dirname_new") or die "can't opendir $dirname_new: $!";
open (FILE, "$imageswap") or die "Cannot open database ($imageswap):$!\n";
##
###open swap file which contains comma delimited data, namely, graphic name and sku
##
while () {
chomp($in = <FILE>);
if ($in) {
($image_name,$newsku)=split(',',$in);
my $dirname="//xyz/Site_graphics/ICS";
opendir(DIR, "$dirname") or die "can't opendir $dirname: $!";
while ($filename = readdir(DIR)){
if ($filename eq $image_name) {
($root,$ext)=$filename=~/(.*)\.(.*)/; # get the root/ext of the file
my $filename_new = "$newsku.$ext";
### this is where I'm stumped. I tried many variations but can't get how to write this to $dirname_new.
}
}
You help would be much appreciated.
Thanks,
Rich
I'm reading a text file which has 2 fields, the existing graphic name, and the corresponding new name. I want to use this file to compare each graphic in a directory and write the newly named graphic to a different directory.
I've gotten up to reading and comparing the text file, but I can't seem write the newly named graphic to a different directory.
Here's what I have so far:
my $dirname_new= "//xyz/Site_graphics/ICS/ICS_new";
opendir(DIR, "$dirname_new") or die "can't opendir $dirname_new: $!";
open (FILE, "$imageswap") or die "Cannot open database ($imageswap):$!\n";
##
###open swap file which contains comma delimited data, namely, graphic name and sku
##
while () {
chomp($in = <FILE>);
if ($in) {
($image_name,$newsku)=split(',',$in);
my $dirname="//xyz/Site_graphics/ICS";
opendir(DIR, "$dirname") or die "can't opendir $dirname: $!";
while ($filename = readdir(DIR)){
if ($filename eq $image_name) {
($root,$ext)=$filename=~/(.*)\.(.*)/; # get the root/ext of the file
my $filename_new = "$newsku.$ext";
### this is where I'm stumped. I tried many variations but can't get how to write this to $dirname_new.
}
}
You help would be much appreciated.
Thanks,
Rich