Answers for "get all files in pc python"

6

find all files in a directory with extension python

import glob, os
os.chdir("/mydir")
for file in glob.glob("*.txt"):
    print(file)
Posted by: Guest on March-06-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

get all files in pc python

import os
 
 
counter = 0
print("If you want all the excel file, for example write .xlsx")
inp = input("What are you looking for?:> ")
thisdir = os.getcwd()
for r, d, f in os.walk("C:\\"): # change the hard drive, if you want
    for file in f:
        filepath = os.path.join(r, file)
        if inp in file:
        	counter += 1
        	print(os.path.join(r, file))
print(f"trovati {counter} files.")
Posted by: Guest on March-15-2022

Python Answers by Framework

Browse Popular Code Answers by Language