How do I delete all png format pics in a folder using Python 3?
This single line statement will take each file in a specified path and remove it if the filename ends in .png
:
import os
os.remove(file) for file in os.listdir('path/to/directory') if file.endswith('.png')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With