Batch file 如何在文件路径中查找字符串,whithin for loop
我需要将某个目录中的某些文件复制到另一个位置,但只复制在其完整路径中包含某些字符串的文件 我试过:Batch file 如何在文件路径中查找字符串,whithin for loop,batch-file,Batch File,我需要将某个目录中的某些文件复制到另一个位置,但只复制在其完整路径中包含某些字符串的文件 我试过: setlocal enableDelayedExpansion set source=c:\temp\*.* set dest=c:\temp\dest\ For %%A in ("%source%") do ( if not x%filename:SOMESTRING=%==x%%A copy %%A %dest% ) 我收到这样一条消息:=A此时是意外的。%filename%的值是
setlocal enableDelayedExpansion
set source=c:\temp\*.*
set dest=c:\temp\dest\
For %%A in ("%source%") do (
if not x%filename:SOMESTRING=%==x%%A copy %%A %dest%
)
我收到这样一条消息:=A此时是意外的。
%filename%
的值是多少?尝试类似于echo%%A^ | find/I“您的字符串以查找”^>nul&©“%%~A”“%dest%”
我不明白您为什么不使用C:\temp\*您要查找的字符串作为%source%
的字符串值,例如设置“source=C:\temp\*要查找的字符串*”
。