utilize python, Get the in the directory file with ‘.png’ Image with suffix , Save as list, And then write txt In file . Other types of files are similar , Modify the corresponding part .
# encoding: utf-8
import os
def to_text(src,dst1):
txt=[]
filenames= os.listdir(src)
# filenames.sort(key= lambda x:(int((x.split('_')[1]).split('.')[0]))) # train_2045.png
filenames.sort(key =lambda x: int(x.split('.')[0])) # 2045.png
#print(filenames)
for item in filenames:
if item.endswith('.png'):
txt.append(item)
fo=open(dst1,'w')
for item in txt:
fo.write(str(item)+'\n')
if __name__ == "__main__":
src=r'F:\all_date\WHU\A'
dst1=r'F:\all_date\WHU\file.txt'
to_text(src,dst1)