Answers for "python code to get all file names in a folder"

17

python get all file names in a dir

from os import listdir
from os.path import isfile, join
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
Posted by: Guest on April-04-2020
0

Get all file in folder Python

path = "C:\code\"

import glob

txtfiles = []
for file in glob.glob(path + "\\*.m4a"):
    txtfiles.append(file)

for item in txtfiles:
    print(item)
Posted by: Guest on November-12-2021
0

python code to get all file names in a folder

#import OS
import os
 
for x in os.listdir():
    if x.is_file():
        # Prints only text file present in My Folder
        print(x)
Posted by: Guest on May-02-2022

Code answers related to "python code to get all file names in a folder"

Python Answers by Framework

Browse Popular Code Answers by Language