【问题标题】:Why .RAR file contains different files with the same name为什么.RAR文件包含同名的不同文件
【发布时间】:2011-09-16 08:22:48
【问题描述】:

我有一个 .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

为什么?

【问题讨论】:

  • WinRAR 完全可以做到这一点。该格式允许多个具有相同名称的条目。如果你不小心告诉 WinRAR 不要存储路径,很容易得到这个。
  • 我很奇怪,为什么人们首先要这样做?

标签: rar


【解决方案1】:

如前所述,文件可能位于不同的路径中,但正如我将进一步展示的那样,情况并非总是如此。

如果你使用 WinRAR 列出文件内容并且你的选项设置如下,那么它只会显示你有同名的文件,但它们在不同的路径中。

  • 选项 -> 文件列表 -> 平面文件夹视图 (ctrl+h)
  • 选项 -> 文件列表 -> 详细信息

在 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

如果您尝试重新添加此文件,rar 将替换已添加的同名文件。

Updating archive rarfile.rar

Updating  testfile.txt                                                     OK
Done

创建另一个文件或重命名第一个文件并将其添加到 RAR 文件中。

move testfile.txt second.txt            (new file)
rar a rarfile.rar second.txt            (add it)
rar lb rarfile.rar                      (list archive, bare info)

将第二个文件重命名为第一个文件的名称。

rar rn rarfile.rar second.txt testfile.txt

这就是您如何在同一路径中创建包含多个同名文件的 RAR 文件。这些步骤在 WinRAR 中是类似的。如果您再次尝试重命名文件,该目录中所有文件的文件名也会更改

为什么有人要这样做?

我能想到的唯一解释是创建此存档的人想要模仿版本控制/备份系统。但是,如果您只想提取一个特定版本而不是第一个,WinRAR 会提取错误的文件。看来我发现了一个非常模糊的 WinRAR 错误 :-)

编辑:在 RAR 文档中找到这个后似乎是一个不好的解释:

-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.

【讨论】:

    【解决方案2】:

    它们很可能处于不同的路径中。

    尝试输出完整路径。或者看看提取它们时会发生什么。

    您可能会看到如下内容:

    index.txt
    path1/index.txt
    path2/index.txt

    等等等等

    【讨论】:

    • 当我将它们解压到一个文件夹时,RAR 一直问我新解压的 index.txt 是否应该覆盖旧的。 RAR 确实有一个选项,以便我可以自动重命名。 index1.txt index2.txt ... 有没有办法获得原始文件夹结构,因为我猜这就是发生的事情。
    猜你喜欢
    • 2012-03-11
    • 2011-01-19
    • 2020-02-16
    • 2022-10-05
    • 2015-12-10
    • 1970-01-01
    • 2015-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多