7zip 不允许在存档名称中使用文件扩展名

7zip 不允许在存档名称中使用文件扩展名
7za.exe a C:\temp\file.txt.7z C:\temp\file.txt
Error:
there is no such archive

为什么 7zip 不允许在存档名称中使用文件扩展名?我甚至尝试在存档名称中使用简单的句点,但它不允许我

  1. file.txt.original压缩后应该file.txt.original.7z
  2. file.txt.20150220压缩后应该file.txt.20150220.7z
  3. file.txt_20150230压缩后应该file.txt_20150230.7z

它不允许我从命令行调用压缩此类文件7za.exe

我需要在这里做什么?请告诉我。

谢谢

答案1

你的命令是错误的。要从 txt 文件创建 7zip 文件,你需要执行以下操作:

C:\Users\Sam>7za a -t7z files.7z *.txt

您编写的命令将寻找一个名为 file.txt.7z 的现有压缩文件并将 file.txt 添加到其中。

答案2

使用“for”循环和通配符

for %f in (file.txt*) do 7za.exe a %f.7z %f 

见下文:注意不同版本的7-zip它仍然是一样的。

C:\temp>for %f in (file.txt*) do "C:\Program Files\7-Zip\7z.exe" a %f.7z %f

C:\temp>"C:\Program Files\7-Zip\7z.exe" a file.txt.20150220.7z file.txt.20150220


7-Zip 17.00 beta (x64) : Copyright (c) 1999-2017 Igor Pavlov : 2017-04-29

Scanning the drive:
1 file, 0 bytes

Creating archive: file.txt.20150220.7z

Add new data to archive: 1 file, 0 bytes


Files read from disk: 0
Archive size: 106 bytes (1 KiB)
Everything is Ok

C:\temp>"C:\Program Files\7-Zip\7z.exe" a file.txt.original.7z file.txt.original


7-Zip 17.00 beta (x64) : Copyright (c) 1999-2017 Igor Pavlov : 2017-04-29

Scanning the drive:
1 file, 0 bytes

Creating archive: file.txt.original.7z

Add new data to archive: 1 file, 0 bytes


Files read from disk: 0
Archive size: 106 bytes (1 KiB)
Everything is Ok

C:\temp>"C:\Program Files\7-Zip\7z.exe" a file.txt_20150230.7z file.txt_20150230


7-Zip 17.00 beta (x64) : Copyright (c) 1999-2017 Igor Pavlov : 2017-04-29

Scanning the drive:
1 file, 0 bytes

Creating archive: file.txt_20150230.7z

Add new data to archive: 1 file, 0 bytes


Files read from disk: 0
Archive size: 106 bytes (1 KiB)
Everything is Ok

相关内容