7-Zip 从命令行重命名 zip 中的根文件夹

问题描述 投票:0回答:1

我正在使用 7-Zip 从命令行创建 .zip 文件。
我有这个目录结构 D:\TEST\ROOT_FOLDER\ 现在我想创建包含 ROOT_FOLDER 下所有文件的 zip 文件,并且 zip 中的根文件夹名称将为 ROOT 而不是 ROOT_FOLDER。

目前我将工作目录设置为 D:\TEST 然后运行它,从我看来 rn 命令仅用于重命名文件而不是文件夹,所以有办法做我想要的吗?

7z.exe a -r D:\\TEST.zip ROOT_FOLDER\* 
command-line 7zip
1个回答
0
投票

创建存档后,您可以使用

rn
命令:

7z.exe a -r D:\TEST.zip ROOT_FOLDER\* 
7z.exe rn D:\TEST.zip ROOT_FOLDER ROOT

--help
标志为您提供有关可用命令的信息:

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
© www.soinside.com 2019 - 2024. All rights reserved.