此代码的输出是:
[ C:\Users\PC\Desktop\Bilder2017\test.jpg ]
[ C:\Users\PC\Desktop\Bilder2017\ ]
[ test.jpg ]
[ test ]
如何获取dir Bilder2017的变量?
@echo off
set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
set dialog=%dialog%close();resizeTo(0,0);</script>"
for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "file=%%p"
echo [ %file% ]
For %%A in ("%file%") do Set Folder=%%~dpA
echo [ %Folder% ]
for %%i in ("%file%") do set "isoname=%%~nxi"
echo [ %isoname% ]
for %%i in ("%file%") do set "name=%%~ni"
echo [ %name% ]
pause
答案 0 :(得分:0)
For %%A in ("%folder%.") do Set "leaf=%%~nxA"
将folder
中的名称视为文件名并获取最后一部分。