Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Lists content of the history folder.
full_file: Full file paths for each file.
file_names: File name and extensions for each file.
# Import libraries
import os
# Declare empty list
file_names = []
full_file = []
# Get directory
path = os.path.split(ghdoc.Path)
dir = path[0] + "\out" # Here I'm declaring a specific folder that contains the files I want to operate on
full_path = os.path.join(dir, '')
# Get directory contents
contents = os.listdir(dir)
# Grab files and add to empty lists
for file in contents:
if file.endswith(".txt"): # you can use any file extension here
full_file.append(full_path + file)
# Grab empty files and delete if prompted
for fp in full_file:
if clear:
if os.stat(fp).st_size == 0:
if os.path.isfile(fp):
except Exception as e:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.