Delete all files from a folder using a bat that match a certain pattern in Windows 10

I want to delete all files in a folder that start with a certain string, for example "File_EXC" and that are .zip files.

2 Answers

  1. CD to the correct path.
  2. DEL FILE_EXC*.ZIP
  3. Press Enter
0

Would it be satisfactory to have it run at shutdown, instead of taking up process cycles by looping every 10 minutes? If so:

Open a Command Prompt, type gpedit.msc and click OK. Expand Computer Configuration | Windows Settings | select Scripts (Startup/Shutdown) .
Double-click Shutdown in the right side pane.
Click Add, and put your batch file's filename and path in there.
Test it by shutting down and restarting, then looking for the files which should have been deleted.

If not, create a second batch file here named LOOPY.BAT which contains:

REM LOOPY.BAT
:loop
command /c batchfilename.bat
timeout /t timeToWaitBetweenCallsInSeconds /nobreak
goto :loop
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like