Reputation: 8448
I have the following line:
for %i in (bin\Setup) do if not %i == setup.exe del %i
This for pretends to delete all files in bin\Setup
except from the one called setup.exe, but it's not working...
Any ideas on what I'm doing wrong?
Upvotes: 0
Views: 74
Reputation: 70923
for %i in ("bin\Setup\*") do if /i not "%~nxi"=="setup.exe" echo del "%~fi"
Changes made:
if
is now case insensitive (/i
)%~nxi
) is tested. You can execute for /?
to retrieve a full list of modifiers available.%~fi
) to itThis is written to be executed from command line. Inside a batch file the percent signs need to be escaped, replacing %
with %%
for %%i in ("bin\Setup\*") do if /i not "%%~nxi"=="setup.exe" echo del "%%~fi"
del
commands are prefixed with a echo
so files are not removed, the command is just echoed to console. If the output is correct, remove the echo
.
Upvotes: 1