我正在尝试读取具有文件路径的文件print.txt
示例:C:\Documents and Settings\Administrator\My Documents\My Pictures\a1.jpg
它已成功读取,但当我尝试将其移动到文件名var时,它没有获得任何值。回声打印为'filename is: filename
FOR /f "tokens=*" %%s in (print.txt) do (
Set filename=" " %%s " "
echo.filename is: %filename
)
答案 0 :(得分:0)
试试这个: -
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f "tokens=* delims=" %%s in (print.lst) do (
echo %%s
Set filename=%%s
echo filename is: "!filename!"
)
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f "tokens=* delims=" %%s in (print.lst) do (
echo %%s
Set filename=%%s
echo filename is: "!filename!"
For %%A in (!filename!) do (
Set Folder=%%~dpA
Set Name=%%~nxA
echo.Folder is: !Folder!
)
)