Hi I need to create file which contain image path in following format
/var/sample/55/cam.png;55
/var/sample/55/desktop.png;55
/var/sample/44/92x92.png;44
/var/sample/44/full.png;44
I am using the following python script for doing this,
BASE_PATH=sys.argv[1]
SEPARATOR=";"
f = open('path.csv', 'w')
for dirname, dirnames, filenames in os.walk(BASE_PATH):
for subdirname in dirnames:
subject_path = os.path.join(dirname, subdirname)
list = glob.glob(subject_path+'/*.png')
for filename in list:
abs_path = "%s" % (filename)
print "%s%s%s" % (abs_path, SEPARATOR, subdirname)
print >>f, "%s%s%s" % (abs_path, SEPARATOR, subdirname)
f.close()
But the above code will list only .png
extension now, I need to include .jpg,.jpeg
etc.. How can I edit the above code to achieve it.
I have already found the answer here but not able to understand how to apply here.
Thanks,
Haris