If I execute the following command (with wildcard in path) in a DOS batch file then the result is not found:
if exist "D:\archive\logs\log*2015\*.zip" ( Echo found)
although such files as
D:\archive\logs\log 04.2015\test.zip
exist!. If I omit the wildcard in the path and just leave the wildcard in filename then it works:
if exist "D:\archive\logs\log 04.2015\*.zip" ( Echo found)
Is this correct?
Is there no way to put wildcards in pathes?
Peter
"if exist" with wildcards in path?
Moderator: DosItHelp
Re: "if exist" with wildcards in path?
Wildcards in paths aren't supported in the if exist command.
Re: "if exist" with wildcards in path?
To be more clear - in general wildcards are only supported in the last element of the entire path.
Regards
aGerman
Code: Select all
for /d %%i in ("D:\archive\logs\log*2015") do if exist "%%~i\*.zip" echo found
Regards
aGerman