Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Delte all %WinDir%\*.bmp BUT ONE.

Featured Replies

I'd like to delete all *.bmp files in %WinDir% but boot.bmp in my cleanup.cmd.

whats the best way to do this?

REN %WinDir%\boot.bmp boot.pmb
del %WinDir%\*.bmp /F /Q
REN %WinDir%\boot.pmb boot.bmp

It's cheap, but you'll be able to figure out what's going on when you look at it again a year from now ;)

Edited by gosherm

@gosherm, exactly they way my head was going with that.

Ok, how about this?

for /F "usebackq" %%i in (`dir /b %WinDir%\*.bmp`) do (
if %%i equ boot.bmp (
REM Found boot.bmp
) else (
del /f /q %%i
)
)

My suggestion is to still use the first solution as

1) it is cleaner and

2) it has less overhead

Edit:

Hmm... I suppose this could actually be simplified a little bit to:

for /F "usebackq" %%i in (`dir /b %WinDir%\*.bmp`) do (
if %%i neq boot.bmp (
del /f /q %%i
)
)

Edited by gosherm

  • Author

Now how about if there are TWO files i'd not like to delete. (Just for learning how this works...)

eg. boot1.bmp and boot2.bmp

Oh.. and it did'nt work ;)

It searched for the file in the location where the batch were executed.

I put a testbatch on C:\ and the result were

C:\>test2.cmd

Finner ikke C:\Blå

Finner ikke C:\Bobler.bmp

Finner ikke C:\Fjær.bmp

Finner ikke C:\Fluefisker.bm

Finner ikke C:\Jade.bmp

Finner ikke C:\Kaffekopp.bmp

Finner ikke C:\Pastell.bmp

Finner ikke C:\Rododendron.b

Finner ikke C:\Santa

Finner ikke C:\Storm

Finner ikke C:\Ullteppe.bmp

Edited by BoardBabe

%windir% is going to be your windows folder (i.e. c:\windows), not the drive root (%systemdrive%). It shouldn't have removed any files from C:\.

As far as multiple files, this is where the second solution gets messy because the IF statement can't handle complex statements (i.e. if (a=b OR a=c) then). So, you're left with:

for /F "usebackq" %%i in (`dir /b %WinDir%\*.bmp`) do (
if %%i neq boot.bmp (
if %%i neq boot2.bmp (
del /f /q %%i
)
)
)

Whereas the first solution gives you:

REN %WinDir%\boot.bmp boot.pmb
REN %WinDir%\boot2.bmp boot2.pmb
del %WinDir%\*.bmp /F /Q
REN %WinDir%\boot.pmb boot.bmp
REN %WinDir%\boot2.pmb boot2.bmp

Edited by gosherm

Hmm... it shouldn't be... though I did find one problem.

Try this as a test:

for /F "usebackq tokens=*" %%i in (`dir /b %WinDir%\*.bmp`) do (
if %%i neq boot.bmp (
if %%i neq boot2.bmp (
echo deleting "%%i"
) else (
echo saving "%%i"
)
) else (
echo saving "%%i"
)
)

and this as the final:

for /F "usebackq tokens=*" %%i in (`dir /b %WinDir%\*.bmp`) do (
if %%i neq boot.bmp (
if %%i neq boot2.bmp (
del /f /q "%%i"
)
)
)

  • Author

Now it does exclude boot.bmp, but it's still something wrong with the path. I put this in test.cmd on c:\ and the result of #2 is (translated):

Could not find C:\Jade.bmp

Could not find C:\Pastell.bmp

etc.

Maybe it should be

del /f /q "%WinDir%\%%i"

?

Doh! I think you're right... I can't believe I missed that.

  • Author

Hehe I was ;)

Thank's for the help!

PS. the (del) /f is not needed as the files are not write protected.

Edited by BoardBabe

  • Author

This seems to work also

for /f "usebackq tokens=*" %%i in (`dir /b "%winDir%\*.bmp"`) do if %%i neq boot.bmp del /q "%WinDir%\%%i"

:thumbup

Edited by BoardBabe

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.