Reputation: 783
I’m using 7-Zip to create a .zip file from command line.
I have this directory structure D:\TEST\ROOT_FOLDER\ now I want to create zip file that include all files under ROOT_FOLDER and also that the root folder name in the zip will be ROOT instead of ROOT_FOLDER.
Currently I set the working directory to D:\TEST and then run this, from what I see rn command is only used to rename files not folders, so it there a way to do what I want ?
7z.exe a -r D:\\TEST.zip ROOT_FOLDER\*
Upvotes: 2
Views: 1315
Reputation: 146540
You can use the rn
("Rename files in archive") command after you've created the archive:
7z.exe a -r D:\TEST.zip ROOT_FOLDER\*
7z.exe rn D:\TEST.zip ROOT_FOLDER ROOT
The --help
flag gives you information about available commands:
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]
<Commands>
a : Add files to archive
b : Benchmark
d : Delete files from archive
e : Extract files from archive (without using directory names)
h : Calculate hash values for files
i : Show information about supported formats
l : List contents of archive
rn : Rename files in archive
t : Test integrity of archive
u : Update files to archive
x : eXtract files with full paths
Upvotes: 1