in reply to Re: Re: File remaing and removal to a subdirectory
in thread File renaming and removal to a subdirectory

The problem is that you have forgotten the / after Xwords. It works fine if you add it.

my $dir = "c:/Xwords/"; my $from = '.puz'; my $to = 'A.puz'; while (<$dir*$from>) { my ($old,$new); $old = $new = $_; $new =~ s/$from$/$to/; rename $old, $new; }

The problem is that the * in the glob is rather like *.* in something like copy *.* a: - if the * matched everything you would not need the . there. In a glob the * will match a filename like 'foo.bar' but not a path/filename like '/foo.bar' Without the trailing / the glob <$dir*$from> is trying to match files in c:/ that match the filename /Xwords\w*.puz/ If you put a file in C:/ called Xwordstest.puz it will get renamed. In the original script the $dir was 'c:/' not 'c:', that is the difference and the problem.

A useful trick when a script does not work is to slip in some print statements to see what is going on. If you place a print in the while loop you will see that the while loop is never entered in your example.

Good to see you back.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print