如何使用 spaces 查找文件名的非 space 版本

How to find the non space version of a file name with spaces

我正在使用 windows 并且需要访问包含 space 的目录和文件名。右键单击文件并选择属性用于显示非 space 短名称,但似乎 windows 7 不再这样做。我也在上班所以无法安装dosbox

我正在尝试为该文件创建一个 file:// url。路径是:

myserver\SHARED ITEMS\My File.txt

如何获得类似于

的名称
file://myserver/shared~1/My~1.txt

了解 spaces in URL and percent encoding。但是,% 在 Windows CLI 和 cmd 批处理文件中具有特殊含义...

阅读8.3 file name creation on NTFS partitions。您可以使用 dir /X 看到 8.3 文件名,假设这些文件已为特定卷启用。但是,它仅适用于 local 驱动器:在 administrator 命令提示符下,可以使用 [=18= 查询 NTFS 文件系统] 效用:

C:\Windows\system32>fsutil.exe behavior query Disable8dot3 c:
The volume state is: 0 (8dot3 name creation is enabled).
The registry state is: 2 (Per volume setting - the default).

Based on the above two settings, 8dot3 name creation is enabled on c:

C:\Windows\system32>fsutil.exe behavior query Disable8dot3 d:
The volume state is: 1 (8dot3 name creation is disabled).
The registry state is: 2 (Per volume setting - the default).

Based on the above two settings, 8dot3 name creation is disabled on d:

C:\Windows\system32>net use y: \SERVER-PC\VB_scripts_help
The command completed successfully.

C:\Windows\system32>fsutil.exe behavior query Disable8dot3 y:
Error:  Access is denied.

此处针对映射驱动器的 FSUTIL behavior query 引发 Access is denied 错误,因为它无法查询 远程 文件系统(可能不是 NTFS nota bene)...

但是即使在启用了 8dot3 名称创建的本地驱动器 上,下一个示例表明 8.3 名称无法明确解析:

==>D:\bat\Whosebug453582.bat

 Directory of C:\testC\New Folder 12

26.05.2015  15:34                 0 NEWTEX~1     New Text File 1
26.05.2015  15:34                 0 NEWTEX~2     New Text File 2
               2 File(s)              0 bytes

 Directory of C:\testC\New Folder 21

26.05.2015  15:34                 0 NEWTEX~2     New Text File 1
26.05.2015  15:34                 0 NEWTEX~1     New Text File 2
               2 File(s)              0 bytes

之前的输出来自下一个批处理脚本:

@ECHO OFF >NUL
MD C:\testC 2>nul
pushd C:\testC
MD "New Folder 12" 2>nul
type NUL>"New Folder 12\New Text File 1"
type NUL>"New Folder 12\New Text File 2"
dir /X   "New Folder 12" | findstr /I /V "Volume"| findstr /I /V "<DIR> free"
MD "New Folder 21" 2>nul
type NUL>"New Folder 21\New Text File 2"
type NUL>"New Folder 21\New Text File 1"
dir /X   "New Folder 21" | findstr /I /V "Volume"| findstr /I /V "<DIR> free"
popd