I have plagiarised tachyon's snippet for renaming files
My modification does not work, and I would appreciate any comments and assistance.
I have left the debugging print statement in, in case anyone wants to set up a dummy folder with some .puz files and an empty subdirectory
Many thanks,
Joe, Townsville
#!/usr/bin/perl -w use strict; my $dir = "c:/Xwords/"; my $n=length "c:/Xwords/"; # There must be a better way of doing t +his => Please?? my $from = '.puz'; my $to = 'A.puz'; my $newdir = "c:/Xwords/PrintedXwords/"; while (<$dir*$from>) { # checking for .puz files my ($old,$new,$full); # declaring variables $old = $full = $_; # setting the full filename and path $new = $old = substr $_,$n; # removing the path details of + filename $new =~ s/$from$/$to/; # changing the old file name print " \n \n"; print " full name of original file is $full \n"; print " name of original file is $old \n"; print " full name of new file is {$newdir.$new} \n"; # does not co +ncatenate - leaves the '.' visible print " \n \n"; rename $full, {$newdir.$new}; } print "Files renamed !"; exit
In reply to Renaming and moving files to a subdirectory by Joes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |