Answers for "save all the file names from a folder in the variable in python"

1

store all files name in a folder python

import os
#this command will store all .txt files in same directories
ALL_FILES_IN_DIR = [ELEM for ELEM in os.listdir() if "txt" in ELEM]

#ALL DIRETORIES 
ALL_DIR = [ELEM for ELEM in os.listdir() if "." not in ELEM]
Posted by: Guest on December-25-2020

Code answers related to "save all the file names from a folder in the variable in python"

Python Answers by Framework

Browse Popular Code Answers by Language