Hi!
I know that this is an easy one, but I am not getting
anywhere. I am using the following code to rename files, but I keep
getting “permission denied”;
#!/perl
use strict;
local( *FI, *FO );
.
.
.
.
sub rename_track_files {
my( $file_path, $file, $DEBUG1, @files ) = @_;
my $file_name = "$file_path\\$file";
print "\n\nrename_track_files
$file_name*\n\n" if $DEBUG1;
my $j = 0;
open( FI, $file_name ) || die "$file_name
$!\n";
while( <FI> ) {
next if /EXTM3U|EXTINF/;
$j++;
#print "act $file_path\\$_";
my $mp = /mp3/ ?
".mp3" : ".mp4";
my $jc = $j < 10 ?
"0$j" : "$j";
my $old_name = "$file_path\\Track
No$jc$mp";
my $new_name =
"$file_path\\$_";
next if $old_name eq $new_name;
next if( ! -e $old_name );
print "$old_name ** $_\n";
print "\n\nTrack No$jc$mp\n\n";
chmod 0777, $old_name;
chdir $file_path;
#my $p = `rename "$old_name"
"$new_name"`;
next if ( rename( "Track
No$jc$mp", $_ ) ) ; # implies successful rename
# next if ( rename($old_name, $new_name) )
; # implies successful rename
print "Error: " , $! ,
"\n";
printf "OldFile: %s\nNewFile:
%s\n",
$old_name,
$new_name;
}
close FI;
}1;
I have verified that the “read only” is not set
on the files and directories. What am I missing?
Thanks,
Jerry