Program code :
import pandas as pd
import os
print(' Picture name extraction in progress ......')
imgPath=os.getcwd()
nameList=os.listdir()
for i in range(len(nameList)):
nameList[i]=os.path.splitext(nameList[i])[0]
df=pd.DataFrame(nameList)
df.to_excel(imgPath+'/A.xlsx')
print(' Picture name extraction completed !')
print('Excel The file saving path is :'+imgPath+'/A.xlsx')
os.system('pause')
If you need to package it into exe File format , You have to go through pyinstaller Tools :
1、 stay cmd Window type
pip install pyinstaller
2、 install pyinstaller After completion , Enter... Directly in the address field of the target folder cmd, stay cmd Window type
pyinstaller -F a.py #-F And then python File name of the file
Can finish exe File generation .
such , Only need to exe Copy the file to the folder to be extracted , double-click exe file , You can extract all file names in the folder , And save the extracted file name to Excel In file .
It should be noted that : Because we put exe Files are also copied to this folder , So the extracted file name contains the exe File name of the file , stay Excel Delete from .