7zip コマンドが指定された出力ディレクトリに解凍されない

7zip コマンドが指定された出力ディレクトリに解凍されない
7z x d:\migration\mongo\mongodb.7z o:f:\data *.* -r

このコマンドをバッチの一部として使用して、7z ファイルの内容を 1 つのドライブ (D) から別のドライブ (F) に抽出します。フォルダー構造は重要なので、x再帰でコマンドを使用しています。

実際には、アーカイブの内容が に解凍されるはずですf:\data

何ですか実際に起こっている内容はバッチファイルのディレクトリ作業ディレクトリ( )に解凍されますf:\migration\-w:コマンドで作業ディレクトリ( )を指定しても効果はありません。

コマンドを意図したとおりに動作させるにはどうすればよいですか?

Windows Server 2012 R2 で 7zip x64 9.22b を使用しています。

編集: 私の最初の質問では、データが同時に 2 つの場所に抽出されていると述べていました。しかし、実際にはそうではありませんでした。私の質問は、これを反映するように更新されました。

答え1

私は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

当然ですが、フォルダー名にスペースが含まれている場合は二重引用符を使用します。

答え2

私の場合、CMD では動作しましたが、Powershell では動作しませんでした。宛先ディレクトリを引用符で囲むと解決しました。

以下はCMDでは動作しますが、Powershellでは動作しません。

7z x d:\migration\mongo\mongodb.7z -of:\data *.* -r

以下は両方で動作します

7z x d:\migration\mongo\mongodb.7z -o"f:\data" *.* -r

関連情報