Need to add a whitelist to my .bat

So I have a .bat that deletes a certain extension, but I need to whitelist a few of them. I'm not having much luck.

xcopy "universe" "C:\Users\Administrator\Desktop\Backup\universe - %stamp%" /I
for %%i in ("universe\*.world") do if not "%%i"=="" if not "%%i"=="" del /q "%%i"

I made a some dummy files, but even and is being deleted with everything else .world. Anyone have any idea?

If possible what I want is a simple text file that lets me add on file names onto it and let it whitelist it from there, because some of the .world names generated are pretty huge in names.


Here's a solution - the /i is needed to match upper and lower case and the %%~nxi matches the filename and extension.

for %%i in ("universe\*.world") do if /i not "%%~nxi"=="" if /i not "%%~nxi"=="" del /q "%%i"

When you are trying to debug batch files ECHO is your friend. Try this:

for %%i in ("universe\*.world") do echo %%i

This will print file names like "universe\", which makes the problem clear.

You need to include the "universe\" in the names you are testing for, for example:

if not "%%i"=="universe\"

You can make your code more readable by splitting it over multiple lines:

for %%i in (universe\*.world) do (
  if not "%%i"=="universe\" (
  if not "%%i"=="universe\" (
    echo %%i

Note that on the line after the ECHO you need as many closing parentheses as you have IF statements.

Need Your Help

Adding custom data attribute to html <option> tag within a @Html.EditorFor in an MVC Razor view razor

I want to add a custom data attribute to each option in my selectlist, which I could achieve with or .attr().

Print character without system calls

assembly x86 nasm qemu osdev

I'm wondering how to print a character in assembly without int 0x80 and other system calls. I am doing this for a kernel. I have a working print function, but I want to write one in assembly, so I ...