Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

7-zip commandline

I'm creating a backup utility that zips all the files listed in a text file. I am using MS ACCESS as my front-end and 7-Zip for compression. These are the commands I am using:

7zG.exe a c:\Backup\backup.zip
@c:\temp\tmpFileList.txt

All the files are compressed without their path. Is there a way to include the path for each file in the zip file? Then when backup.zip is extracted the files would be restored to their original folder structure.

Thanks

like image 791
Arnold Avatar asked Sep 02 '09 08:09

Arnold


2 Answers

In this 7-zip forum thread, in which many people express their desire for this feature, 7-zip's developer Igor points to the FAQ question titled "How can I store full path of file in archive?" to achieve a similar outcome.

In short:

  • separate files by volume (one list for files on C:\, one for D:\, etc)
  • then for each volume's list of files,
    1. chdir to the root directory of the appropriate volume (eg, cd /d C:\)
    2. create a file listing with paths relative to the volume's root directory (eg, C:\Foo\Bar becomes Foo\Bar)
    3. perform 7z a archive.7z @filelist as before with this new file list
    4. when extracting with full paths, make sure to chdir to the appropriate volume's root directory first
like image 62
Anonymous Avatar answered Sep 29 '22 09:09

Anonymous


The command-line program for 7-Zip is 7z or 7za. Here's a helpful post on the options available. The -r (recurse) option stores paths.

like image 39
Vinay Sajip Avatar answered Sep 29 '22 10:09

Vinay Sajip