Cha*_*evy 4 windows command-line 7-zip
7z x d:\migration\mongo\mongodb.7z o:f:\data *.* -r
Run Code Online (Sandbox Code Playgroud)
我将此命令用作批处理的一部分,以将 7z 文件的内容从一个驱动器 (D) 提取到另一个驱动器 (F)。文件夹结构很重要,所以我使用x递归命令。
应该发生的是存档内容被解压缩到f:\data.
什么是实际发生的事情是内容被解压到批处理文件的目录的工作目录(f:\migration\)。-w:在命令中指定工作目录 ( ) 无效。
如何让我的命令按预期工作?
我在 Windows Server 2012 R2 上使用 7zip x64 9.22b。
编辑:我最初的问题指出数据被提取到两个同时的地方。事实证明,情况并非如此。我的问题已更新以反映这一点。
我正在使用 7za.exe(命令行版本),但 7z.exe 也是如此。仔细看一下帮助信息:
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Usage: 7za <command> [<switches>...] <archive_name> [<file_names>...]
[<@listfiles...>]
<Commands>
a: Add files to archive
b: Benchmark
d: Delete files from archive
e: Extract files from archive (without using directory names)
l: List contents of archive
t: Test integrity of archive
u: Update files to archive
x: eXtract files with full paths
<Switches>
-ai[r[-|0]]{@listfile|!wildcard}: Include archives
-ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
-bd: Disable percentage indicator
-i[r[-|0]]{@listfile|!wildcard}: Include filenames
-m{Parameters}: set compression Method
-o{Directory}: set Output directory
-p{Password}: set Password
-r[-|0]: Recurse subdirectories
-scs{UTF-8 | WIN | DOS}: set charset for list files
-sfx[{name}]: Create SFX archive
-si[{name}]: read data from stdin
-slt: show technical information for l (List) command
-so: write data to stdout
-ssc[-]: set sensitive case mode
-ssw: compress shared files
-t{Type}: Set type of archive
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
-v{Size}[b|k|m|g]: Create volumes
-w[{path}]: assign Work directory. Empty path means a temporary directory
-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
-y: assume Yes on all queries
Run Code Online (Sandbox Code Playgroud)
你看到它是如何清楚地提到开关是-o和-w?就像在开关前面有一个连字符,但没有命令。另外,结肠是不开关本身的一部分。如果是,那么您应该使用类似的方法,x:而不仅仅是x用于提取路径。因此,您对o:<Path>和的奇怪用法w:<Path>是您头痛的原因。
使用这样的东西来递归压缩文件夹并存储相对路径:
7za a -r Archive.7z C:\InputFolder
Run Code Online (Sandbox Code Playgroud)
使用以下命令解压到特定目录:
7za x -oD:\OutputFolder Archive.7z
Run Code Online (Sandbox Code Playgroud)
显然,如果您的文件夹名称中有空格,请使用双引号。
| 归档时间: |
|
| 查看次数: |
11817 次 |
| 最近记录: |