Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: move files to directories based on criteria

by ikegami (Pope)
on Jul 10, 2009 at 19:05 UTC ( #779011=note: print w/replies, xml ) Need Help??


in reply to move files to directories based on criteria

return if $File::Find::dir ne $root_dir;

You're traversing an entire tree even though you ignore all results from subdirectories. Very wasteful! I think the solution is:

sub wanted { my ($file)=$_; if (-d $file) { $File::Find::prune = 1; return; } my $dir_to_make = categorize($file); File::Path::make_path($dir_to_make); File::Copy::move($file, $dir_to_make); }

Error checking would be useful.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://779011]
help
Chatterbox?
[choroba]: I had 24.5 in January, but the last three month are below 18.5
[choroba]: and I'm trying hard not to get involved in troll feeding.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2017-04-26 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (475 votes). Check out past polls.