···11+# Script to go through a given directory recusively and remove files based on file extension
22+33+import os
44+55+"""
66+Directory path should be formatted as follows:
77+ '<disk>:/path/to/file
88+ example: C:/Users/test/testUser/Downloads
99+"""
1010+directoryToUse = <insert path to top folder here>
1111+1212+for subdir, dirs, files in os.walk(directoryToUse):
1313+ for file in files:
1414+ if file.endswith("<add file extension in quotes"):
1515+ #os.remove or os.unlink both work here as their functionality is identical, remove comes from windows, unlink from UNIX
1616+ os.remove(os.path.join(directoryToUse, file))