Rar的帮助文件中只说了
e       解压文件到当前目录。但我想在解压时就改名(因为不想覆盖目录下已有的同名文件)当然,这些参数都应该是程序在后台调用Rar.exe 直接运行,不给出提示信息完成的。请问该怎么做?我要解压的有很多文件,而且解压Rar是异步执行的,
如果一边解压一边移动改名,总是有很大时间差异的,
对于本身就是异步的解压,再加上异步的移动改名,简直乱透了(事实上为了不干扰前台程序的运行,它们确实需要后台异步操作,但这样几乎就无法控制了)另外一个可能情况,当解压文件很大时,比如一个整盘的GHO文件(这是一个极端的但有可能的例子)当这样一个大的文件解压后再移动改名,这
就该死的Rar烦,诶还有一个例子,我要将压缩包中的一批带路径的文件解压到一单一目录的文件夹中,
可能会引起重名文件的问题,这时候,在每个文件解压前就需要以我的规则来解决重名文件(比如加前缀或加后缀或加计数等等)
而解压时不能直接改名,那可麻烦死了

解决方案 »

  1.   

    那就要看 RAR 是否给你这样的接口了。
    如果你要 RAR 算法自己写解压程序,当然就没有问题。
      

  2.   

    rn  改Rar里的文件名,如果不想改压缩里的文件名在截压之后再改回来 Rename files inside of archive. This command is supported only for RAR archive format. The command syntax is:
       winrar rn <arcname> <srcname1> <destname1> ?<srcnameN> <destnameN>
    For example, the following command:
       winrar rn data.rar readme.txt readme.bak info.txt info.bak
    will rename readme.txt to readme.bak and info.txt to info.bak in the archive data.rar.
    It is allowed to use wildcards in the source and destination names for simple name transformations like changing file extensions. For example:winrar rn data.rar *.txt *.bak
    will rename all *.txt files to *.bak.
    WinRAR does not check if the destination file name is already present in the archive, so you need to be careful to avoid duplicated names. It is especially important when using wildcards. Such command is potentially dangerous, because a wrong wildcard may corrupt all archived names.