Solved

Batch FIle: 7ZIP

Posted on 2010-08-16
5
853 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 51

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

760 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

23 Experts available now in Live!

Get 1:1 Help Now