获取文件或文件夹的短路径- @echo off
- set strPath='C:\Users\dub\AppData\Roaming\Adobe\InDesign\Version 19.0-J'
- powershell -c "$path=%strPath%;$a=New-Object -ComObject Scripting.FileSystemObject;if(Test-Path $path){if($a.FileExists($path)){$f=$a.GetFile($path)}else{$f=$a.GetFolder($path)};Write-Host $f.ShortPath}else{Write-Host '路径不存在'}"
- pause
复制代码
- '&cls&cscript -nologo -e:vbscript "%~f0" "C:\Users\dub\AppData\Roaming\Adobe\InDesign\Version 19.0-J"&pause&exit
- strPath = WScript.Arguments(0)
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FileExists(strPath) Then
- Set f = objFSO.GetFile(strPath)
- WScript.Echo f.ShortPath
- ElseIf objFSO.FolderExists(strPath) Then
- Set f = objFSO.GetFolder(strPath)
- WScript.Echo f.ShortPath
- Else
- WScript.Echo strPath & " 路径不存在"
- End If
复制代码
|