Answers for "find name of file in directory python"

7

list files in directory python

import os
print(os.listdir('/path/to/folder/to/list'))
Posted by: Guest on April-22-2020
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 "find name of file in directory python"

Python Answers by Framework

Browse Popular Code Answers by Language