I finally managed to move my files. posting the code. this is dependent on being in the correct path of the sourcetree when it is ran, it will recurse directories grabbing text files and move them to the directory specified in $dir2. however something odd happens if there are no txt files, I get this as output. Output when there are no files within subdirectories in move.pl actually it doesn't seem to matter whether ther are files or not, what have I done, it worked yesterday today its toast and my deadline is tomorrow :( ./Documents and Settings/aanderso/Local Settings/Application Data/Microsoft/Inte rnet Explorer brndlog.txt this is c:\mlx\ this would be c:\mlx\./Documents and Settings/aanderso/Local Settings/Applicatio n Data/Microsoft/Internet Explorer this should be c:\mlx\/./Documents and Settings/aanderso/Local Settings/Applicat ion Data/Microsoft/Internet Explorer/brndlog.txt do you see the problem yet? Unable to move No such file or directory at c:\inetpub\performancetesting\output \new\1.pl line 66.
use DirHandle; use File::Find; use File::Copy; use Data::Dumper; use strict; use warnings; my $dir= "."; my $dir2="c:\\mlx\\"; lista_dirs($dir,$dir); #lista_dirs2($dir2,$dir2); sub lista_dirs{ my ($dir, $dirname) = @_; my (@dirs, @files); opendir DIR, "$dir"; my @dircontent = grep { /[^\.]/ } readdir(DIR); closedir DIR; # opendir DIR2, "$dir2"; #my @dircontent2 = grep { /[^\.]/ } readdir(DIR); #closedir DIR2; # @dirs2=(); #@files2=(); @dirs = (); @files = (); foreach(@dircontent) { if(-d "$dir/".$_) { push @dirs, $_; } else { push @files, $_ if($_ =~ /\.txt$/); } } #foreach(@dircontent2){ #if(-d "$dir2/".$_) { #push @dirs2, $_; #} else { # push @files2, $_ if($_ =~ /\.txt$/); #} #} foreach my $d(@dirs) { lista_dirs("$dir/" .$d, $d); } foreach my $file (@files) { $/ = ''; print $dir, "\n"; print $file, "\n"; print "this is $dir2 \n"; print "this would be $dir2$dir \n"; print "this should be $dir2/$dir/$file \n"; print "do you see the problem yet? \n"; move ("$dir/$file","$dir2/$dir/$file") or die "Unable to move $!"; } return; }

In reply to move files revisited by grashoper

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.