Batch command 'for' is not working -
i have following line:
for %i in (bin\setup) if not %i == setup.exe del %i this pretends delete files in bin\setup except 1 called setup.exe, it's not working...
any ideas on i'm doing wrong?
for %i in ("bin\setup\*") if /i not "%~nxi"=="setup.exe" echo del "%~fi" changes made:
- wildcard included enumerate files in folder.
ifcase insensitive (/i)- file references quoted avoid problems spaces
- only name , extension of file (
%~nxi) tested. can executefor /?retrieve full list of modifiers available. - removal of file uses full path (
%~fi) it
this written executed command line. inside batch file percent signs need escaped, replacing % %%
for %%i in ("bin\setup\*") if /i not "%%~nxi"=="setup.exe" echo del "%%~fi" del commands prefixed echo files not removed, command echoed console. if output correct, remove echo.
Comments
Post a Comment