Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: 7zip a folder

by soonix (Canon)
on Nov 03, 2017 at 07:43 UTC ( [id://1202664]=note: print w/replies, xml ) Need Help??


in reply to Re^2: 7zip a folder
in thread 7zip a folder

I second dasgar's answer, especially the first paragraph. That said, I have compressed things using something like the following, which would compress all .txt files in current and subdirs into target.zip:
... use Data::Dumper; ... my @cmd = ( 'c:\Program Files\7-Zip\7z.exe', 'a', '-mx9', '-r', 'target.zip', '*.txt', ); print 'about to execute: ', Dumper \@cmd; system @cmd;
The 7zip man page is not on their home page, but over there you can have a glance.

Replies are listed 'Best First'.
Re^4: 7zip a folder
by ytjPerl (Scribe) on Nov 06, 2017 at 15:15 UTC
    Hi Soonix, It is working, Thanks! I am just wondering if there is a command to zip file and also delete what we've archived. Or we just zip files then to delete them using two steps. Thanks
      You'd have to implement this yourself. It seems to me the creators of 7-zip aren't willing to implement this because it is too easy to destroy a freshly created archive after all the files are compressed and deleted.
        Basically, what I am doing now is to move all the files falling into my date range to a new folder which foldername is the timestamp of those files, then zip all the file under this folder, I could not get it through, because it is saying \$foldername\ the system cannot find the path specified.
        $date = strftime("%Y-%m-%d", localtime); mkdir my $foldername = "D:/log_script/Archive/$date"; my @cmd = 'D:/app/7-Zip/7z.exe', 'a', '-mx9', 'D:/log_script/Archive/target.zip', '$foldername/*.log' ); print 'about to execute: ', Dumper \@cmd; system @cmd;
        Hi Soonix, Can I also ask you what is the 9 meaning in -mx9? Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1202664]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found