我有一个.RAR文件,其中包含具有相同名称的不同文件.
例如,
index.txt 40 Text Document 04/01/2010 4:40PM
index.txt 22 Text Document 04/01/2010 4:42PM
index.txt 10 Text Document 04/01/2010 4:45PM
index.txt 13 Text Document 04/01/2010 4:50PM
Run Code Online (Sandbox Code Playgroud)
为什么?
如前所述,文件可能位于不同的路径中,但正如我将进一步展示的那样,情况并非总是如此.
如果使用WinRAR列出文件内容并且您的选项设置如下,则只显示您具有相同名称的文件,但它们位于不同的路径中.
在列CRC32之后,有一个名为Path.如果这是不同的,在以下情况下提取应该不是问题:
如果是不提取路径,WinRAR将需要请求您重命名它们,因为文件系统限制.我假设命令行unrar在这种情况下不会成为问题,因为您需要指定其他参数来更改其默认行为.
RAR存档可能在同一目录中具有多个具有相同名称的文件.如果您使用Windows,请在以下示例中的命令行上使用"C:\ Program Files\WinRAR\Rar.exe" 而不是rar.
创建一个新文件并将其添加到RAR存档.您还可以通过列出其内容来检查更改.
rar a rarfile.rar testfile.txt
rar l rarfile.rar
rar a rarfile.rar testfile.txt
Run Code Online (Sandbox Code Playgroud)
如果您尝试重新添加此文件,rar将使用相同的名称替换已添加的文件.
Updating archive rarfile.rar
Updating testfile.txt OK
Done
Run Code Online (Sandbox Code Playgroud)
创建另一个文件或重命名第一个文件并将其添加到RAR文件.
move testfile.txt second.txt (new file)
rar a rarfile.rar second.txt (add it)
rar lb rarfile.rar (list archive, bare info)
Run Code Online (Sandbox Code Playgroud)
将第二个文件重命名为第一个文件的名称.
rar rn rarfile.rar second.txt testfile.txt
Run Code Online (Sandbox Code Playgroud)
这是在同一路径中创建具有多个同名文件的RAR文件的方法.这些步骤在WinRAR中类似.如果您尝试再次重命名该文件,该目录中所有文件的文件名也将更改.
为什么有人想要这样做?
我能想到的唯一解释是,创建此存档的人想要模仿版本控制/备份系统.但是,如果您只想提取一个特定版本并且它不是第一个,WinRAR会提取错误的文件.好像我发现了一个非常模糊的WinRAR错误:-)
编辑:在RAR文档中找到后,似乎是一个不好的解释:
Run Code Online (Sandbox Code Playgroud)-ver[n] File version control Forces RAR to keep previous file versions when updating files in the already existing archive. Old versions are renamed to 'filename;n', where 'n' is the version number. By default, when unpacking an archive without the switch -ver, RAR extracts only the last added file version, the name of which does not include a numeric suffix. But if you specify a file name exactly, including a version, it will be also unpacked. For example, 'rar x arcname' will unpack only last versions, when 'rar x arcname file.txt;5' will unpack 'file.txt;5', if it is present in the archive. If you specify -ver switch without a parameter when unpacking, RAR will extract all versions of all files that match the entered file mask. In this case a version number is not removed from unpacked file names. You may also extract a concrete file version specifying its number as -ver parameter. It will tell RAR to unpack only this version and remove a version number from file names. For example, 'rar x -ver5 arcname' will unpack only 5th file versions. If you specify 'n' parameter when archiving, it will limit the maximum number of file versions stored in the archive. Old file versions exceeding this threshold will be removed.