在重命名截断时删除原始匹配文件

时间:2014-08-12 16:59:27

标签: file windows-7 filenames delete-file truncate

我的一个朋友被Krypto病毒击中。值得庆幸的是他们安装了Carbonite。因此,他们继续前进并仅恢复受影响的文件(.xls,.doc,jpg,扫描等......有一堆)。不幸的是,他们没有恢复所有可以大大简化这一切的东西。

已经对目录中的碳酸盐进行了恢复..现在我们有正确的文件(它们都有字符串:(已恢复)从结尾的第28个字符开始。另外我们还有其他有效文件krypto DID NOT加密。

不幸的是,碳酸盐岩还原的任何人只放置了选定的文件(xls,doc,ppt等)并将其他文件保留原样。所以我不能只删除所有文件。当我截断名称时...另一个文件存在。 (他们被Krypto病毒冻死了)......所以我只想让它们消失。但我必须保留其他未受影响的文件。

所以我假设我在目录中有以下文件

afile1 (Restored) 11-23-2010 14.07.DOC (this filename would be truncated at 
                                       the " ("   since there is already a file 
                                       called afile1.doc in the directory. 
afile1.doc                             (This file needs to be DELETED BEFORE the truncation
                                       the above filename so no conflict with duplicate FN 

break.txt                              (This file has no matching file 
                                       with Restored in the name, leave alone)
cat.zip                                (This file has no matching file 
                                       with Restored in the name, leave alone)
fred (Restored) 01-14-14 13.28.JPG     (This filename would be truncated at the " (" 
                                       but first, again the file below would have to be deleted
fred.jpg                               (This file needs to be deleted before the truncation 
                                       of the above filename so it won't create duplicate file

到目前为止,我正试图弄明白......(或者我可能错过的任何其他内容!)

我怎么能

  1. 测试是否存在匹配的文件名,其中“(已恢复)”已存在具有该名称的现有文件(如上例所示(afile1.doc& fred.jpg)
  2. 删除已存在的文件(或至少“prepend deleteme to flie,我们将不得不手动删除???然后
  3. 然后在其中截断文件名的最后28个字符(已恢复),使其正确命名并在正确的位置,从而防止重复文件情况或更糟糕的是,将字符添加到有效文件的末尾
  4. 我必须为目录下的所有文件执行此操作。 (有无数目录存放文件)。

    我需要留下以下文件:

    afile1.doc  (this was the file that had (Restored) in the name and was truncated)
    break.txt
    cat.zip
    fred.jpg    (this was another file that had (Restored) in the name and was truncated)
    

    我希望这是有道理的。

0 个答案:

没有答案