cesapun has asked for the wisdom of the Perl Monks concerning the following question:
Hello !
I'm trying to write a perl script that search for rar files(and eventually,unrar them into a folder) in a directory that has subdirs.
For example,let's say that i have dir "archive" and this dir contains "cd1","cd2" etc.
Script will get as argument "archive" and will search into it for rar files.Of course,it will open "cd1","cd2" dirs and unrar the content into another folder.
By now,i have a script that search for rar files and unrar only from a dir.But i don't know how to make it to search in every folder.
opendir(DIR, $show_dir); #Opens The Directory my @tempfiles = grep(/\.rar$/,readdir(DIR)); #Scans for files +ending in .rar closedir(DIR); #Closes The Directory my $rar_file = $tempfiles[0]; #Chooses First .rar File Found $rar_file = "$show_dir\/$rar_file"; #Adds Full Path To Rar Fil +e Name my $rar_command = "unrar e \"$rar_file\" \"$output_rar\""; #Cr +eates The Command Used To Unrar print "[INFO] Unraring file, Please Wait.\n"; #Alerts The User + That We Are Going To Unrar `$rar_command`; #Unrars The File
Can someone help me with this?
Many thanks in advance
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: unrar from multiple directories
by 2teez (Vicar) on Aug 09, 2012 at 19:23 UTC | |
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 |
Back to
Seekers of Perl Wisdom