+ 1
How do i index specific file type like .jpg,gif,mp4 and print in .txt file
I want an algorithm for Printing only the name of the file with file extension Then put them in folder I have tried using is os.system but failed 😅
2 Respostas
+ 3
strawdog
os.system('dir,c:\\users\\yash\\desktop\\*.jpg')#is working
but
for filename in os.system('dir,c:\\users\\yash\\desktop\\*.jpg')
print(filename) #not working
and
for filename in gob.iglob(r'c:\\dir\\*.jpg')#not working
even i have use variable for getting the data
thanku for giving the idea for this > \*.jpg
+ 1
Use glob module (either alone or along with os module) like this
import glob
for filename in glob.iglob(r'D:\dir\*.jpg'):
print(filename)