Personal Project Portfolio
python bash powershell
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add file removal python script

+16
+16
scripting/fileRemoval.py
··· 1 + # Script to go through a given directory recusively and remove files based on file extension 2 + 3 + import os 4 + 5 + """ 6 + Directory path should be formatted as follows: 7 + '<disk>:/path/to/file 8 + example: C:/Users/test/testUser/Downloads 9 + """ 10 + directoryToUse = <insert path to top folder here> 11 + 12 + for subdir, dirs, files in os.walk(directoryToUse): 13 + for file in files: 14 + if file.endswith("<add file extension in quotes"): 15 + #os.remove or os.unlink both work here as their functionality is identical, remove comes from windows, unlink from UNIX 16 + os.remove(os.path.join(directoryToUse, file))