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


In reply to unrar from multiple directories by cesapun

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.