in reply to Re^3: Perl - Copy files to a newly created folder
in thread Perl - Copy files to a newly created folder
Alexander, this is my current code: (after I changed what I told you in my previous message, and it did not change anything)
#!/usr/bin/perl -w use File::Copy; use warnings; $dir="C:/Users/Beni/Documents/Master 2/_DOSSIERS/_Perl/dossiertest"; $cpt=0; print"Souhaitez-vous supprimer les fichiers copies du dossier racine u +ne fois la copie terminee ? (oui/non) : "; chomp ($del = <>); opendir(DIR,$dir) or die $! ; while($folder=readdir (DIR)) { if ( -f "$dir/$folder") { $folder =~m/(.+)?\.(.+)?/; if ( -d "$dir/Fichiers $2") { copy ("$folder","$dir/Fichiers $2/$folder"); } else { $dirr = $dir . '/' . "Fichiers " . $2; mkdir ("$dirr"); copy ("$folder","$dir/Fichiers $2") or die $! ; } $cpt++; if ($del=~m/^oui$/i) { unlink ("$dir/$folder") or die $! ; } } } print"$cpt copies effectuees"; close (DIR);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Perl - Copy files to a newly created folder
by afoken (Chancellor) on Apr 18, 2015 at 23:54 UTC |