I can get the files to copy but I cannot get the directories to create. See sub movefiles and sub move directory.
#!C:\NTRESKIT\perl #use File::Copy; #does C:\ntapps\common\C exist? #add user notification using Win32::Console $startdir = "\\ntapps\\common\\c"; @filespec = ('exe', 'dll'); @filedelete = glob ("\\junk\\save\\*.*"); #@cmd = ('dir'); $savedir = 'C:\junk\save'; #sub searchDirectory; #sub builddirectory; if (-e "\\ntapps\\common\\c"){ #Find all EXE's and DLL's open (OUTFILE, '>\ntapps\log\mv_common_c.lst'); searchDirectory($startdir,"",@filespec); #removing files from junk\save unlink @filedelete; #rename files using the system system ("rename" ,'C:\junk\save\*.*', '*.old'); close (OUTFILE); movefiles(); }else print "missing \n"; } # use THIS TO FIND EXE'S AND DLL's sub searchDirectory { # $startdir is a path name, @filespec is a list of file extensions only(ie: exe, dll, ...) local($basedir,$startdir,@filespec) = @_; local(@lines); local($subdir); local($lvl_counter); local($list_length); #print "got to search directory\n"; if(opendir (DIR,$basedir.$startdir)) { @lines = readdir (DIR); closedir (DIR); $lvl_counter = 2; $list_length = ( scalar @lines ); while ($lvl_counter < $list_length) { $subdir = $startdir."\\".$lines[$lvl_counter]; if(!searchDirectory($basedir,$subdir,@filespec)) { processnames($startdir.'|'.$lines[$lvl_counter],@filespec); } $lvl_counter++; } }else { return 0; } return 1; } sub processnames { # Give the value passed to this sub a sensible name. my ($filename,@filespec) = @_; $match = join '|', @filespec; if ($filename =~ /($match)$/i) { print (OUTFILE "$filename\n"); } } sub movefiles { local ($name, $path, $filename, $topath); #This is moving the files on the list we created to junk\save #open input file print "inputlist\n"; open (INPUTLIST, '<\ntapps\log\mv_common_c.lst'); foreach $file (<INPUTLIST>) { ($path,$name) = split (/\|/, $file); if (!-e $savedir.$path."\\" && !$path == "" ) { $topath = $savedir.$path; print "path:$path\n"; print "making directory: $topath\n"; #mkdir ($topath, 0777) || die "cannot mkdir $topath: $!"; `C:\\john\\ldapps\\perl\\buildir.pl $savedir, $path`; ##closedir dumb; } if (!-d $basedir ) {print "ouch\n" } $command = 'copy '.$startdir.$path."\\".$name.' C:\junk\save'.$path; print "$command\n"; print "path:$topath, name:$filename\n"; system ($command); last; } close (INPUTLIST); } #this assumes that basedir exists sub builddirectory { local ($basedir, @path) = @_; local ($directory); @sublist = ($path <1) ? (split(/\\/, $path[0])) : (@path) ; print "$#path, $#sublist, @path, @sublist\n"; foreach $directory (@sublist) { if ($directory =~ /\s/) { next; } if (!-e $basedir.'\\' .$directory) { mkdir($basedir. '\\' .$directory, 0777); } $basedir .= '\\'.$directory; print "$basedir\n"; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]