7z x d:\migration\mongo\mongodb.7z o:f:\data *.* -r
我将此命令用作批处理的一部分,以将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
您会清楚地看到开关是-o
和的-w
。如图所示,在开关之前有一个连字符,但没有命令。另外,结肠是不开关本身的一部分。如果是这样,那么您应该使用类似的方法,x:
而不仅仅是x
使用路径提取。因此,您的怪异的使用o:<Path>
和w:<Path>
对你头痛的原因。
使用类似这样的方法来递归压缩文件夹并存储相对路径:
7za a -r Archive.7z C:\InputFolder
使用以下命令解压缩到特定目录:
7za x -oD:\OutputFolder Archive.7z
显然,如果您的文件夹名称中包含空格,请使用双引号。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句