![7zip 不允许在存档名称中使用文件扩展名](https://linux22.com/image/1445390/7zip%20%E4%B8%8D%E5%85%81%E8%AE%B8%E5%9C%A8%E5%AD%98%E6%A1%A3%E5%90%8D%E7%A7%B0%E4%B8%AD%E4%BD%BF%E7%94%A8%E6%96%87%E4%BB%B6%E6%89%A9%E5%B1%95%E5%90%8D.png)
7za.exe a C:\temp\file.txt.7z C:\temp\file.txt
Error:
there is no such archive
为什么 7zip 不允许在存档名称中使用文件扩展名?我甚至尝试在存档名称中使用简单的句点,但它不允许我
file.txt.original
压缩后应该file.txt.original.7z
file.txt.20150220
压缩后应该file.txt.20150220.7z
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