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 :: draw a line pygame 
Python :: python check if is pandas dataframe 
Python :: install python 3.9 linux 
Python :: matplotlib label axis 
Python :: cv2.imshow 
Python :: load images pygame 
Python :: python how to set the axis ranges in seaborn 
Python :: python convert number to base 
Python :: pandas series remove punctuation 
Python :: axis font size matplotlib 
Python :: change type of array python 
Python :: make first row columns pandas 
Python :: with font type stuff python turtle 
Python :: how to disable help command discord.py 
Python :: A value is trying to be set on a copy of a slice from a DataFrame. 
Python :: python check if folder is empty 
Python :: cannot remove column in pandas 
Python :: plotly set axes limits 
Python :: format integer to be money python 
Python :: grid in pygame 
Python :: generate a list of random numbers python 
Python :: python print only 2 decimals 
Python :: check pip for conflicts 
Python :: list to json python 
Python :: list of prime numbers in python 
Python :: django form password field 
Python :: import NoSuchKey in boto3 
Python :: columns to dictionary pandas 
Python :: select items from dataframe where value is null 
Python :: python prompt for input 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =