如何强制 Windows 重命名带有特殊字符的文件?

cod*_*Les 89 windows rename filenames special-characters

我有一首 Windows 无法播放的歌曲,因为文件名中有一个问号。

"Where Have All the Cowboys Gone?.ogg" // as an example
Run Code Online (Sandbox Code Playgroud)

所以我尝试重命名它,Windows 会抱怨我是在资源管理器中还是在命令提示符下尝试。

尝试复制、重命名或移动时出现的错误是:

文件名、目录名或卷标语法不正确

在这种情况下,是否有强制重命名的Windows方法?

更新

我会密切关注这个问题,但经过 13 个答案和多次尝试(除了第 3 方解决方案),似乎 Windows 无法做到这一点(或者至少我的 Windows 不能,没有短名称)。所以我接受答案,这是我使用 Linux 的原始解决方案。很高兴看到 Windows 以某种方式处理这个问题,所以不要因为我已经接受了这个答案而停止,问题仍然存在!

sal*_*ose 44

拿一个 linux live-cd 并使用它。

  • 最近像 ubuntu 这样的 linux 发行版成功地支持了 NTFS 最重要的功能。 (4认同)

GAT*_*awn 29

您是否尝试过使用其名称的短文件名版本?例如

ren whereh~1.ogg where.ogg
Run Code Online (Sandbox Code Playgroud)

如果它是当前文件夹中唯一以前几个字母开头的文件,则使用名称的前 6 个字母(忽略空格),然后是波浪号 (~),然后是 1。

  • 由于短名称的生成是可选的,具体取决于 Windows 当前的配置方式,墨菲说 OP 已关闭短名称,而文件将没有短名称。要了解任何文件是否存在短名称,请使用 DIR/X,它将添加一列,显示任何文件的短名称,其中它与长名称不同,如果有的话。如果有一个简短的名字,这将是一个合理的答案。 (13认同)
  • 没有短名称,尝试了您的示例,并且 dir/x 证明没有列出任何名称。 (4认同)

小智 25

  1. 在 Windows 7 中:在管理员模式下运行 cmd.exe。
  2. cd 进入带有文件名的目录。
  3. 运行: chkdsk /V /f [我的坏文件在操作系统驱动器以外的另一个驱动器上,因此它能够卸载它。如果是操作系统驱动器,则可能必须在启动时执行此阶段。]
  4. 等待(可能必须重新启动)。

正如您将看到的结果是 chkdsk 实际上为我删除了文件。所以,如果你想保留这些文件,我不知道该怎么做,但这肯定会摆脱这些文件。

结果/命令日志:

E:\islag\Music\llb>dir
 Volume in drive E is FreeAgent Drive
 Volume Serial Number is 5038-892A

 Directory of E:\islag\Music\llb

02/02/2011  12:18 PM    <DIR>          .
02/02/2011  12:18 PM    <DIR>          ..
04/04/2010  02:19 PM         4,014,099 01 Los Lonely Boys - Se?orita - www.file2
4ever.com.mp3
04/04/2010  02:18 PM         3,125,942 12 Los Lonely Boys - La Contestaci?n - ww
w.file24ever.com.mp3
               2 File(s)      7,140,041 bytes
               2 Dir(s)  87,743,991,808 bytes free

E:\islag\Music\llb>chkdsk /V
The type of the file system is NTFS.
Volume label is FreeAgent Drive.

WARNING!  F parameter not specified.
Running CHKDSK in read-only mode.

CHKDSK is verifying files (stage 1 of 3)...
  231424 file records processed.
File verification completed.
  34 large file records processed.
  0 bad file records processed.
  0 EA records processed.
  0 reparse records processed.
CHKDSK is verifying indexes (stage 2 of 3)...
18 percent complete. (29338 of 245164 index entries processed)
An invalid filename 01 Los Lonely Boys - Se?orita - www.file24ever.com.mp3 (3196
6) was found in directory 31962.
All filenames for File 31966 are invalid.
Minor file name errors were detected in file 31966.
An invalid filename 12 Los Lonely Boys - La Contestaci?n - www.file24ever.com.mp
3 (31973) was found in directory 31962.
All filenames for File 31973 are invalid.
Minor file name errors were detected in file 31973.
73 percent complete. (233817 of 245164 index entries processed)
Index entry 01 Los Lonely Boys - Se?orita - www.file24ever.com.mp3 in index $I30
 of file 31962 is incorrect.
Index entry 12 Los Lonely Boys - La Contestaci?n - www.file24ever.com.mp3 in ind
ex $I30 of file 31962 is incorrect.
  245164 index entries processed.
Index verification completed.

Errors found.  CHKDSK cannot continue in read-only mode.

E:\islag\Music\llb>dir
 Volume in drive E is FreeAgent Drive
 Volume Serial Number is 5038-892A

 Directory of E:\islag\Music\llb

02/02/2011  12:18 PM    <DIR>          .
02/02/2011  12:18 PM    <DIR>          ..
04/04/2010  02:19 PM         4,014,099 01 Los Lonely Boys - Se?orita - www.file2
4ever.com.mp3
04/04/2010  02:18 PM         3,125,942 12 Los Lonely Boys - La Contestaci?n - ww
w.file24ever.com.mp3
               2 File(s)      7,140,041 bytes
               2 Dir(s)  87,743,991,808 bytes free

E:\islag\Music\llb>chkdsk /V /f
The type of the file system is NTFS.
Cannot lock current drive.

Chkdsk cannot run because the volume is in use by another
process.  Chkdsk may run if this volume is dismounted first.
ALL OPENED HANDLES TO THIS VOLUME WOULD THEN BE INVALID.
Would you like to force a dismount on this volume? (Y/N) y
Volume dismounted.  All opened handles to this volume are now invalid.
Volume label is FreeAgent Drive.

CHKDSK is verifying files (stage 1 of 3)...
  231424 file records processed.
File verification completed.
  32 large file records processed.
  0 bad file records processed.
  0 EA records processed.
  0 reparse records processed.
CHKDSK is verifying indexes (stage 2 of 3)...
18 percent complete. (29339 of 245164 index entries processed)
Deleted invalid filename 01 Los Lonely Boys - Se?orita - www.file24ever.com.mp3
(31966) in directory 31962.
File 31966 has been orphaned since all its filenames were invalid
Windows will recover the file in the orphan recovery phase.
Correcting minor file name errors in file 31966.
Deleted invalid filename 12 Los Lonely Boys - La Contestaci?n - www.file24ever.c
om.mp3 (31973) in directory 31962.
File 31973 has been orphaned since all its filenames were invalid
Windows will recover the file in the orphan recovery phase.
Correcting minor file name errors in file 31973.
73 percent complete. (233642 of 245164 index entries processed)
Deleting index entry 01 Los Lonely Boys - Se?orita - www.file24ever.com.mp3 in i
ndex $I30 of file 31962.
Deleting index entry 12 Los Lonely Boys - La Contestaci?n - www.file24ever.com.m
p3 in index $I30 of file 31962.
  245164 index entries processed.
Index verification completed.
CHKDSK is scanning unindexed files for reconnect to their original directory.
  2 unindexed files scanned.
CHKDSK is recovering remaining unindexed files.
  2 unindexed files recovered.
CHKDSK is verifying security descriptors (stage 3 of 3)...
  231424 file SDs/SIDs processed.
Cleaning up 41 unused index entries from index $SII of file 9.
Cleaning up 41 unused index entries from index $SDH of file 9.
Cleaning up 41 unused security descriptors.
Security descriptor verification completed.
  6871 data files processed.
CHKDSK is verifying Usn Journal...
  1116928 USN bytes processed.
Usn Journal verification completed.
Correcting errors in the master file table's (MFT) BITMAP attribute.
Windows has made corrections to the file system.

 244196000 KB total disk space.
 158175168 KB in 30003 files.
     22820 KB in 6873 indexes.
         0 KB in bad sectors.
    306168 KB in use by the system.
     65536 KB occupied by the log file.
  85691844 KB available on disk.

      4096 bytes in each allocation unit.
  61049000 total allocation units on disk.
  21422961 allocation units available on disk.

E:\islag\Music\llb>dir
 Volume in drive E is FreeAgent Drive
 Volume Serial Number is 5038-892A

 Directory of E:\islag\Music\llb

02/02/2011  12:18 PM    <DIR>          .
02/02/2011  12:18 PM    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  87,743,979,520 bytes free

E:\islag\Music\llb>
Run Code Online (Sandbox Code Playgroud)

  • @ enb081 不,这不应该是答案,因为它与问题没有任何关系,即如何**重命名**文件。嘘。 (5认同)

Jos*_*hua 14

尝试指定 UNC 路径(请参阅命名文件、路径和命名空间)。这绕过了各种限制。你会使用\\?\语法来做到这一点。

例如,如果你的文件在你的桌面上(你的 Windows 驱动器是 C:),你可以做

copy "\\?\C:\Users\codeLes\Desktop\Where Have All the Cowboys Gone?.ogg" "\\?\C:\Users\codeLes\Desktop\Where Have All the Cowboys Gone.ogg"
Run Code Online (Sandbox Code Playgroud)

注意:您不能在此语法中使用相对路径;您必须指定完整路径。它不适用于ren命令,但适用于copymove

  • 试一试,运气不好“文件名、目录名或卷标语法不正确。” 谢谢!我已经到了我认为正确答案是使用 Linux 重命名它的地步(我已经这样做了)。 (4认同)

小智 12

chkdsk有时会修复无效的文件名。您将收到一条关于删除文件的消息,因为所有文件名都无效,然后恢复丢失的文件。然后您可以在C:\found.000\file0000.chk. 这是删除问题文件的有效方法,但如果您想保留它们,则不是最好的方法。


小智 12

我删除顽固文件的方法是打开7zip,找到文件并通过7zip重命名文件。我的是一首歌曲,文件末尾有一个空格。

  • 7zip 能够重命名您的文件,因为以空格结尾的文件名在 Windows 中不是问题。文件名包含“?”是一个问题,7zip 无法重命名它们。 (2认同)

小智 8

使用Recuva。它主要用于恢复已删除的文件,但它也可以选择在扫描中包含未删除的文件。

启动 Recuva 后,拒绝向导并选择正确的磁盘。然后转到选项,找到并选中“扫描未删除的文件”选项并启动扫描。一段时间后,它会显示磁盘上的所有文件(无论是否删除)。找到名称无效的文件(名称已在视图中修复),选择它们,右键单击并保存(“恢复”)某处。

在此处输入图片说明

我刚刚完成了(在 Windows XP 上)。


bra*_*rry 5

尝试使用第三方工具,例如Ken Rename工具:

肯重命名的屏幕截图

重命名 Master

在此处输入图片说明

这是文件重命名工具的列表

我会自己测试它们,但我运行的是 Windows Vista 64 位;文件处理可能不同。

如果这些工具失败,您可能想尝试一下Windows PowerShell。请参阅Windows PowerShell 博客上的重命名文件


use*_*068 5

Microsoft 工具 DISKEDIT.EXE 是用于直接读取和写入原始磁盘数据的低级工具。您应该能够加载包含此文件的目录条目的集群,并且只需更改有问题的 '?' 字符到无害的东西并将其写回磁盘。

据我了解,Microsoft diskedit 工具(不是同名的 Norton Utilities 工具,仅适用于 FAT 卷)最后一次出现在 Windows 2000 SP4 中。但是可以在此处找到它的链接。

要找到正确的集群,您可以下载DiskExplorer for NTFS的试用版。

您可以从 File->Drive... 开始,打开包含此错误文件的驱动器。选择 Goto->Root Directory 以获取目录视图。使用 MFT# 链接导航到包含错误文件的目录。当您到达那里时,窗口顶部会显示类似“MFT# x12345 DIR: 'dirname', ...等等等等...从集群x9302AE开始,...等等等等”

现在转移到 Microsoft diskedit。首先执行 File->Open... 并指定 Volume Name C:(如果文件在您的 C: 驱动器上)。将卷文件名留空。将起始簇号输入到 diskedit 下 Read->NTFS Clusters...->Starting Cluster(输入为十六进制数)。

现在使用箭头键向下滚动到错误的文件名。它是 unicode 格式,因此您将寻找诸如“Where .Have .All .the .Cowboys .Gone?...ogg”之类的内容。 _')。选择 Write->It 将其写回磁盘。

还有另一个地方可以击中(不确定是否需要一个或两个)。现在,返回 DiskExplorer,单击错误文件的 Mft#。你会得到一个屏幕,左边有一个树,上面写着“结构”。单击树中的“属性”。它将显示一个属性列表,其中一个属性类似于 $30 ... $FILE_NAME。因此,$30 具有文件名。单击 Structures 树中 $30 节点下的 Body 节点。选择菜单 View->as Hex。向下几行,您应该再次看到文件名 Where .Have.. 等。在屏幕左侧,您将看到 Sector 列,它显示您正在查看的磁盘扇区。

回到磁盘编辑。执行 Read->Sectors... 并从 DiskExplorer 输入扇区号。和以前一样,向下滚动并将“3F”字符替换为与上面相同的字符。选择 Write->It 将其写入磁盘。

我做了所有这些,工具告诉我我改变了角色,但资源管理器没有。该目录必须缓存在某处。重新启动后,更改变得可见。


小智 5

如果您安装了 Cygwin,它应该能够处理该文件。我刚刚遇到了这个问题,并且在没有 Windows 应用程序(包括资源管理器)以及尝试使用带有 CMD.exe 的 UNC 文件规范帮助时,在 bash shell 中使用 Cygwin 中的 rm 能够很好地删除文件。

我想如果您想保留文件, mv 会这样做。

一个准系统 Cygwin 设置只需要几分钟,无论如何我总是保留它,因为有很多好的工具。它比引导 Linux 更容易,甚至使用 Live CD。