want to delete pdf files from the directory using python.
Having "pdffiles" name folder in that lost of pdf are there So I want to delete all files from it but don't want to delete folder, want to delete just file from folder. how can I do it.(may be using os.remove()
)
Asked
Active
Viewed 504 times
2

psw
- 45
- 1
- 9
-
No this is not remove all folder . want to remove all files from folder – psw Nov 15 '18 at 09:53
-
1@Mike Scotty, Thanks its working...... – psw Nov 15 '18 at 10:03
1 Answers
4
Try listdir
+remove
:
import os
for i in os.listdir('directory path'):
if i.endswith('.pdf'):
os.remove(i)

U13-Forward
- 69,221
- 14
- 89
- 114