web analytics

How to delete all files of specific type/extension from all sub-folders recursively Windows 11

After I have downloaded a backup of All my photos videos stored in google photos using the Google’s takeout method, it was huge folder containing hundreds of thousands of photos and videos and other files and folders.

There were just too many files, and many files which did not need, such as some .JSON files.

To cleanup, I needed to delete all the .JSON files from all the folders and sub folders. Doing that manually would take me an eternity along with a huge change of deleting necessary files such photos and videos.

So, I looked for an easier way to do that.

I found that I could have done that in just one click on a button by using Windows PowerShell.

Steps to delete all files of specific type

Step 01

Open Windows PowerShell with Administrative privileges

Step 02

Move to the root directory that contains all the files and folders

Step 03

Run the following command to delete all *.json files. That is, to delete all the files with extension .json. If you want to delete other types or extensions, then replace that .json with the one that need to delete

Get-ChildItem -Path . -Filter *.json -Recurse | Remove-Item -Force

Cautions

  • You might want to take a backup of the files
  • You can optionally run this following command to see which files are about to be deleted
Get-ChildItem -Path . -Filter *.json -Recurse

The above command will print out all the files that will be deleted if you append ” | Remove-Item -Force” part to that command

Thank you. Take a moment to share 🙏