我在循环遍历路径名包含空格的文件时遇到问题
SET MPATH=\\server\path\some folder with space\Sample.txt
for /f %%a in ("%MPATH%") do (set file=%%~fa)
for /f "skip=1 tokens=2,160 delims=^|" %%a in (%file%) do (
echo something^|%%a^|something^|%%b^|>>"C:\Directory\temp.txt"
)
输出:
The system cannot find the file \\server\path\some.
我查看了多个帖子,建议:
- ..在(“\server\path\some folder with space\Sample.txt”)中执行(设置文件=%%~fa)
- .. in ('dir /b /s \server\path\some folder with space\Sample.txt')
- .. in ('输入 \server\path\some folder with space\Sample.txt')
但似乎都没有起到作用,结果是一样的:
The system cannot find the file specified.