find all files in a directory with extension python
import glob, os
os.chdir("/mydir")
for file in glob.glob("*.txt"):
print(file)
find all files in a directory with extension python
import glob, os
os.chdir("/mydir")
for file in glob.glob("*.txt"):
print(file)
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)
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.")
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us