我使用的是Windows,需要访问包含空格的目录和文件名。右键单击文件并选择属性用于显示非空格短名称,但似乎Windows 7不再这样做。我也在工作,所以我无法安装dosbox。
我正在尝试为该文件创建一个file:// url。路径是:
myserver\SHARED ITEMS\My File.txt
如何获得类似
的名称file://myserver/shared~1/My~1.txt
答案 0 :(得分:2)
了解spaces in URL和percent encoding。但是,%
在Windows CLI和cmd
批处理文件中具有特殊含义...
阅读8.3 file name creation on NTFS partitions。您可以使用8.3
查看dir /X
个文件名,假设某些卷已启用。但是,它仅适用于本地驱动器:在 administrator 命令提示符下,可以使用NTFS
实用程序查询fsutil.exe
文件系统:
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\StackOverflow\30453582.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