in reply to unrar from multiple directories
But i don't know how to make it to search in every folder.
One of the ways of doing that, is using either a recursive subroutine, or use File::Find module.
Using a recursive subroutine:
For Example: To list out all the files in different folders in a directory like so:
This can even get simplier using a File::Find module like so:use warnings; use strict; scan_dir( $ARGV[0] ); ## call subroutine sub scan_dir { my ($dir) = @_; if ( -d $dir ) { ## check if directory opendir my $dh, $dir or die "can't open directory: $!"; while ( readdir $dh ) { next if $_ eq '.' or $_ eq '..'; print $_, $/; scan_dir("$dir/$_"); ## recursive call } } }
NOTE:Please, that the codes above is to show how you can transverse a dircetory. To get your rar files, and "unrar", is left for you to figure out. Am sure you will get around it! :)use warnings; use strict; use File::Find qw(find); find(\&scan_dir,$ARGV[0]); sub scan_dir{ return if $_ eq '.' or $_ eq '..'; print $_,$/; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: unrar from multiple directories
by cesapun (Acolyte) on Aug 09, 2012 at 19:38 UTC | |
by cesapun (Acolyte) on Aug 09, 2012 at 19:44 UTC | |
by Anonymous Monk on Aug 10, 2012 at 00:22 UTC |