Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python delete all files in directory

import os

filelist = [ f for f in os.listdir(mydir) if f.endswith(".bak") ]
for f in filelist:
    os.remove(os.path.join(mydir, f))
Comment

delete all files in a directory python

import os
mydir = "example/"
filelist = [f for f in os.listdir(mydir) if f.endswith(".bak") ]
#if f ends with .bak: change this to any file entension
for f in filelist:
    os.remove(os.path.join(mydir, f))
Comment

PREVIOUS NEXT
Code Example
Python :: remove all integers from list python 
Python :: case statement in querset django 
Python :: remove idx of list python 
Python :: python input lowercase 
Python :: sum of column in 2d array python 
Python :: how to check if string is camelcase python 
Python :: django models using Value 
Python :: runtime.txt heroku python 
Python :: how to create my own exception in python 
Python :: python tkinter define window size 
Python :: django on_delete options 
Python :: pandas transpose 
Python :: reverse text python 
Python :: make averages on python 
Python :: max pooling tf keras 
Python :: python get volume free space 
Python :: python reduce() 
Python :: convert data type object to string python 
Python :: python chat application 
Python :: how to check if given number is binary in pytho 
Python :: python random integer in range 
Python :: python datetime to seconds 
Python :: save a torch tensor 
Python :: qradiobutton example 
Python :: cannot safely cast non-equivalent float64 to int64 
Python :: Python program to check Co-Prime Number 
Python :: how to create a virtual environment in python 3 
Python :: create an array string using for in python 
Python :: random sample with weights python 
Python :: tkinter yes no dialogue box 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =