Skip to content

Instantly share code, notes, and snippets.

@bzd111
Created July 25, 2022 13:12
Show Gist options
  • Save bzd111/042cd67c8fd21087ee68223a6343137a to your computer and use it in GitHub Desktop.
Save bzd111/042cd67c8fd21087ee68223a6343137a to your computer and use it in GitHub Desktop.
python remove file use pathlib
from pathlib import Path
for i in Path('.').glob('*.mp4'):
print(i)
i.unlink()
for i in Path('.').glob('*.m4a'):
print(i)
i.unlink()
for i in Path('.').glob('*.pdf'):
print(i)
i.unlink()
for i in Path('.').glob('**/*.pdf'):
print(i)
i.unlink()
for i in Path('.').glob('**/*.m4a'):
print(i)
i.unlink()
for i in Path('.').glob('**/*.mp4'):
print(i)
i.unlink()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment