Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

For the file example, I would like to delete all files matching .+?[a-f0-9]{4}.html (i.e. any html file ending in a four digit hexadecimal). So paged47c.html would be deleted, but page.html would remain.

For the folder example, I would like to delete all folders matching .+?[A-Z]+ (i.e. any folder containing a capital letter). So some-folderSE93_89ds/ would be deleted, but some-folder/ would remain.

I don't work much with the command line, but I could probably get an example involving "del" to work for me. Alternatively, is there a simple GUI program for Windows that would do this?

share|improve this question

2 Answers 2

I would say the easiest way, albeit not the direct route, is to do your specialized dir command (you can use /b and /s switched to make it just list the filename and to recurse directories) and redirect it to a file. Open it in notepad (or insert your favorite editor), search and replace to add "del " to the beginning of the lines, save it off as mydel.bat, and execute.

So an example would be:

dir /s /b *.html > mydel.bat
notepad mydel.bat
call mydel.bat

share|improve this answer

Use the following line in powershell:

Get-ChildItem -Recurse C:\| where { ! $_.PSIsContainer } | Where-Object {$_.Name -match ".+?[a-f0-9]{4}.html"}

Is for the file case, for the folder case use:

Get-ChildItem -Recurse C:\| Where-Object { $_.PSIsContainer }| Where-Object {$_.Name -match ".+?[A-Z]+"}

Store those both in variables, and then use Remove-Item

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.