Skip to content

Instantly share code, notes, and snippets.

@KrisYu
Last active November 1, 2021 20:00
Show Gist options
  • Save KrisYu/14caa25113b1f3e4a3afbd70d3a991d7 to your computer and use it in GitHub Desktop.
Save KrisYu/14caa25113b1f3e4a3afbd70d3a991d7 to your computer and use it in GitHub Desktop.
delete some files in a path
import os
files = os.listdir()
# files is a string list
for filename in files:
print(filename)
# https://askubuntu.com/questions/443830/delete-all-files-whose-filenames-contain-a-particular-string
# remove a file with *text using shell
# rm *text*
# or run with python3
# os.system('rm *line*')
# os.system('rm *hybrid*')
# os.system('rm *traditional*')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment