ivory has asked for the wisdom of the Perl Monks concerning the following question:

I need some help...I have been asked to write a script that will move files and change directories on a windows system. the move will be something like: P:\Project#\Discipline\xxx.dwg or .doc or .xls --to-- P:\Discipline\Project#\xxx.dwg etc. Any help you all could give me I would greatly appreciate! Thanks! Ivory

Replies are listed 'Best First'.
Re: help moving files
by Odud (Pilgrim) on Jun 28, 2000 at 23:37 UTC
    You probably should look at File::Copy (to move the files) and File::Find to locate the files in the first place. This will do it one file at a time. Or are you thinking about something like the UNIX mv command moving whole directories?
      The following is some hastily bashed together code to show what I mean. It works for me but you should add error handling etc.
      #!/usr/bin/perl use warnings; use File::Copy; use File::Find; find(\&wanted, 'c:\\Pete'); sub wanted { if ($File::Find::name =~ /\.pl$/) { my $copyname = "c:\\folderb/$_"; print "Copying $_ from $File::Find::dir to $copyname\n"; copy("$File::Find::name","$copyname"); } }
      It finds all the .pl files in c:\Pete and sub-directories and copies them into c:\folderb.

      Look at the documentation to find out about the special variables that are available to the subroutine.

      Hope this helps.
Re: help moving files
by davorg (Chancellor) on Jun 29, 2000 at 13:05 UTC