Batch file 将%%var移动到字符串变量的批处理脚本

Batch file 将%%var移动到字符串变量的批处理脚本,batch-file,Batch File,我正在尝试读取文件print.txt,该文件具有文件路径 示例:C:\Documents and Settings\Administrator\My Documents\My Pictures\a1.jpg 它读取成功,但当我试图将它移动到filename var时,它没有得到任何值。echo打印为”文件名为:filename FOR /f "tokens=*" %%s in (print.txt) do ( Set filename=" " %%s " " echo.filename is:

我正在尝试读取文件
print.txt
,该文件具有文件路径

示例:
C:\Documents and Settings\Administrator\My Documents\My Pictures\a1.jpg

它读取成功,但当我试图将它移动到filename var时,它没有得到任何值。echo打印为
”文件名为:filename

FOR /f "tokens=*" %%s in (print.txt) do ( 
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!"
)
更新2
你的档案里有什么?单线?或多行url?多行url的每行1个url示例:C:\Documents and Settings\Administrator\My Documents\My Pictures\1431309.jpg C:\Documents and Settings\Administrator\My Documents\My Pictures\a1.jpg C:\Documents and Settings\Administrator\My Documents\My Pictures\a2.jpg C:\Documents and Settings\Administrator\My Pictures\a1.jpg C:\Documents and SettingsDocuments\My Pictures\a3.jpg C:\Documents and Settings\Administrator\My Documents\My Pictures\a4.jpgyes..尝试使用Print.Lst扩展名保存文件并运行脚本,但仍然存在相同的问题。它们正常工作..但现在面临下一个问题无法获取文件夹名split echo.filename是:!文件名!对于(%filename%)中的%%A,请执行(Set Folder=%%~dpA Set Name=%%~nxA echo。文件夹为:%Folder%),很抱歉,现在循环不会以秒为单位。对于(%filename%)中的%%A,请(…不打印回音。文件夹为:。请帮助他完成此操作,我会将其标记为已回答。
@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! 
 )
)