Created
June 19, 2020 22:52
-
-
Save excenter/fa658b0029f62166714d4687d65d681e to your computer and use it in GitHub Desktop.
sometimes you need to delete a lot of flacs by extension, and xargs didn't feel right.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def filterExtensions(file): | |
# change this extension to whatever you need expunged from the directory | |
filter = ".flac" | |
if file.endswith(filter): | |
return True | |
else: | |
return False | |
directory = '.' | |
files = os.listdir(directory) | |
filteredFiles = filter(filterExtensions, files) | |
for file in filteredFiles: | |
print(file) | |
path_to_file = os.path.join(directory, file) | |
os.remove(path_to_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment