Answers for "python list files in directory with extension"

18

python list files in current directory

import os

files = os.listdir('.')
print(files)
for file in files:
  # do something
Posted by: Guest on November-04-2020
5

how to search for a specific file extension with python

import glob, os
os.chdir("/mydir")
for file in glob.glob("*.txt"):
    print(file)
Posted by: Guest on March-06-2020
0

list files in directory python with extension

import glob, os
os.chdir("/mydir")
for file in glob.glob("*.txt"):
    print(file)
Posted by: Guest on April-23-2021
1

get list of files in directory python

import os
path = '/folder1/folder2/'
files = os.listdir(path)
Posted by: Guest on January-20-2021

Code answers related to "python list files in directory with extension"

Python Answers by Framework

Browse Popular Code Answers by Language