How to delete files with specified text in their names?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game Looping
--
Chapters
00:00 How To Delete Files With Specified Text In Their Names?
00:31 Accepted Answer Score 20
01:17 Answer 2 Score 9
01:47 Thank you
--
Full question
https://superuser.com/questions/932515/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows7 #windows
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Game Looping
--
Chapters
00:00 How To Delete Files With Specified Text In Their Names?
00:31 Accepted Answer Score 20
01:17 Answer 2 Score 9
01:47 Thank you
--
Full question
https://superuser.com/questions/932515/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows7 #windows
#avk47
ACCEPTED ANSWER
Score 20
I want to filter out all files that have a specific part in their name
You can do this with wildcards.
From a command line
To display matching files:
dir *_bad.jpg
To delete matching files:
del *_bad.jpg
Use the /s
option to match files in subdirectories as well as the current directory.
From Explorer
To display matching files:
- enter
*_bad.jpg
in the search box
To delete matching files:
- enter
*_bad.jpg
in the search box, select the results and press Delete or Del
Further reading
ANSWER 2
Score 9
You can do this easilly using PowerShell :
Get-Childitem -path c:\path -Filter *.jpg -Recurse | where-object {$_.Name -ilike "*_bad*"} | Remove-Item -Force -WhatIf
This little script will delete every JPG files located under c:\path (and subfolders), containing "_bad" in their name.
Simply change the root path to match your needs. The -whatif parameter used at the end of the script permits to see what files will be deleted. Remove this switch when your are ready to delete them.
Hope this helps !