Solved

Batch FIle: 7ZIP

Posted on 2010-08-16
5
872 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 54

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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This is about my first experience with programming Arduino.
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…

726 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