omegaweaponZ has asked for the wisdom of the Perl Monks concerning the following question:
After this, I'm looking to actually move the files and sub-folders of those files from the base current directory to the new current directory. Any thoughts? Thank you!$dir = '/current/directory/'; $newdir = '/new/directory/'; find(\&movefiles, $dir); sub movefiles { $move_file = $File::Find::name; $move_curDir = $File::Find::dir; $move_curFile = $_; $move_basedir = dirname($move_curDir); $file_time = (stat($move_file))[9]; $current_time = time; $time_dif = $current_time - $file_time; if ($time_dif <= 300) { #Ignore } else { #Move my $new_file = $move_file; $new_file =~ s/old_folder/new_folder/; copy("$move_file","$new_file") or die "Copy failed: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Move all files and folders older than 5 minutes
by GotToBTru (Prior) on May 01, 2015 at 14:02 UTC | |
by omegaweaponZ (Beadle) on May 01, 2015 at 14:32 UTC | |
by GotToBTru (Prior) on May 01, 2015 at 14:38 UTC | |
by omegaweaponZ (Beadle) on May 01, 2015 at 15:01 UTC |