468x60

giovedì 28 maggio 2009

Eseguire 7-Zip da uno shell script

Se occorre eseguire 7-Zip in modalità batch attraverso uno script, è possibile farlo dalla shell con il seguente comando:
7z.exe action [options] filename[.zip] file(s)
action
aAdd - create a new archive, or add files to an existing archive
dDelete - remove files from an existing archive
eExtract - unarchive files
lList - display the contents of an archive
tTest - validate the integrity of an archive
uUpdate - overwrite existing files in an existing archive
xExtract - same as “e”, except that the files are restored to their exact original locations (if possible)

options
-xExclude file(s), as shown above
-tThe type of archive to create (-t7z, -tzip, -tgzip, -tbzip2 or -ttar). -t7z is the default.
-rRecurse subdirectories
-sfxCreate a self-extracting archive
-mx=9This can be any number from 0 to 9, where 0 means no compression (just store the files), and 9 means maximum compression (takes longer). -mx=5 is the default, a compromise between the amount of compression obtained, and the time required to perform the compression.
-ospecifies the output directory (for when extracting). The default is to use the current directory.
-uUpdate options. this switch works in conjunction with the add, delete, and update commands to determine conflict resolution. For example, what happens when a file being added to an archive already exists in the archive and the timestamp on the source file is older than the timestamp in the archive. Should the file in the archive be left alone, or overwritten?
-vCreate Volumes — This switch allows you to specify the maximum size for an archive file. If the archive file would be bigger than that, 7-Zip will automatically split it into multiple volumes. this will ensure that its the archive files can fit on whatever storage media you have at hand.

filename.zip
Specifica il nome del file Zip coinvolto. Specificare il nome completo del file (inclusa la directory).

files
E' una lista di uno o più files, oppure il carattere @ seguito dal nome del file che contiene la lista dei files da aggiungere, un nome per linea. Wildcards (e.s. *.bak) sono permessi.


Esempi:

7z.exe a -tzip c:\output.zip c:\myfiles\

Se ci sono spazi usare gli apici nel seguente modo:
7z.exe a -tzip c:\output2.zip "c:\My Documents\file1.doc"

Nessun commento:

Posta un commento

468x60

Cerca su Google

Cerca nel Blog con Google