Solved

Batch FIle: 7ZIP

Posted on 2010-08-16
5
857 Views
Last Modified: 2012-08-14
Hi there,

I need to use 7Zip to sequently add & compress files by keeping their full path.

Output compression must have highest compression rate and if it gets greater than 2GB, must create a new file with a sequential number:

For example:
has-been_01.zip
has-been_02.zip


@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%A in ('dir /s /b .\Documents') do (
  7z.exe ...
  )


Thanks for your help,
Rene
0
Comment
Question by:ReneGe
  • 3
5 Comments
 
LVL 52

Assisted Solution

by:Bill Prew
Bill Prew earned 100 total points
ID: 33450839
I don't think you are going to be able to do this with 7Z. I'm not aware of any way to add a single file with it's complete path.  Paths only get stored with wild cards and recursive mode, but that would add all the files at once, and not check the 7z output file size after each file.  You'll probably;y have to look at more robust tools like WinZip or WinRar for these types of advanced capabilities.

~bp
0
 
LVL 4

Accepted Solution

by:
BasiKobrA earned 400 total points
ID: 33452324
Hey,
As billprew told you, 7zip does not support 'absolute path'.

Citing the FAQ at http://www.7-zip.org/faq.html:
How can I store full path of file in archive?
7-Zip stores only relative paths of files (without drive letter prefix). You can change current folder to folder that is common for all files that you want to compress and then you can use relative paths:
  cd /D C:\dir1\
  7z.exe a c:\a.7z file1.txt dir2\file2.txt

So if you want to use 7zip, you could go to the combined top level directory and zip everything from there. But at extraction time, you'd need to be in the same combined top directory...


For the splitting in 2gig blocks, you can add the switch '-v2g'
Cite man page:
v{Size}[b|k|m|g]
Create volumes


For the example you gave, that would be:
7z.exe a -r -v2g -mx=9 yourArchive.7z Documents
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33454114
==> billprew
Thanks for your contribution.  I see that my "keeping their full path" requirement was not possible.

==> BasiKobrA,
Your comand line works. I will then do as you suggested. Create the archive within the full path, containing the compressed file.

************************************************************************

1) Would it be possible to the archive keep NTFS security and Audit settings. If not please advise.
2) How do I add the option of excluting files, by using a text file that will contain the exclusion parameters.  (-x...) (exclude.ini contains: *.mp3, *.wav, *.avi)

Thanks,
Rene
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33454336
I'll create 2 new threads for my 2 previous questions, so you can make more points.
I will prove you with the links when done.

Cheers,
Rene
0
 
LVL 10

Author Comment

by:ReneGe
ID: 33454475
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now