Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python remove file with pattern

import os
import glob

# Get a list of all the file paths that ends with .txt from in specified directory
file_list = glob.glob('/home/varung/Documents/python/logs/*.log')

# Iterate over the list of filepaths & remove each file.
for file_path in file_list:
    try:
        os.remove(file_path)
    except:
        print("Error while deleting file : ", file_path)
Comment

python remove file with pattern

import os
import glob

# Get a list of all the file paths that ends with .txt from in specified directory
file_list = glob.glob('/home/varung/Documents/python/logs/*.log')

# Iterate over the list of filepaths & remove each file.
for file_path in file_list:
    try:
        os.remove(file_path)
    except:
        print("Error while deleting file : ", file_path)
Comment

PREVIOUS NEXT
Code Example
Python :: get drive path python 
Python :: plt python two axis 
Python :: isodate in python 
Python :: how to count number of records in json 
Python :: save imag epillow 
Python :: program to add first and last digit of a number in python 
Python :: best ide for python 
Python :: random pick between given things python 
Python :: how to copy the list in python 
Python :: push in python 
Python :: numpy random 
Python :: multiprocessing in jupyter notebook 
Python :: csv manipulation python 
Python :: pow() Function Function in python 
Python :: boxplot python 
Python :: python loc 
Python :: split string python 
Python :: df concat multiple columns 
Python :: how to check if python is installed on mac 
Python :: #remove a sublist from a list-use remove method 
Python :: WARNING: This is a development server 
Python :: snake water gun game in python 
Python :: largest number python 
Python :: print binary tree python 
Python :: creating a python virtual environment 
Python :: producer and consumer problem in python 
Python :: django save object in view 
Python :: 16 bit floating point numpy 
Python :: python tree 
Python :: open a python script on click flask 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =