Batch FIle: 7ZIP

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
LVL 10
ReneGeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewCommented:
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
BasiKobrACommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ReneGeAuthor Commented:
==> 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
ReneGeAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.