I've copied the program, created test files & directories, and moved files successfully under a Unix system using this program.

I would suggest stepping through the program with a debugger or adding a print join " ", @files; print "\n"; at the end of your loop to find if your @files array is getting munged somehow. That is where my first guess at the problem would be.

My second guess would involve permission issues and or failure of the move as suggested by others.

And my final guess would involve issues with your installation of perl under windows...

My working test code

#!/usr/bin/perl use File::Copy; @files = ("ATMCAF00", "ATMCAF01", "ATMCAF12", "ATMCMF01", "ATMCMF12"); $old = "."; $new = "/ATM/"; print "Enter the month and day (ex:0605)\n"; $date = <stdin>; chomp($date); foreach my $file (@files) { print "Moving $old$file to $new$file$date \n"; if(move("$old$file","$new$file$date")) { print "$file has been moved\n"; } else { print "Error moving $old$file <$!>\n"; } print "---------------------------------------------\n"; } print "All the ATM files have been renamed and move to the ATM folder\ +n"; $wait = <stdin>;

-Scott

In reply to Re^4: Moving files by 5mi11er
in thread Moving files by SteveS832001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.