# import libraries
import os
import pandas as pd
from glob import glob
# Configure Folder path
mybooks = glob(r"FOLDERPATH\**\*.xls*",recursive=True)
df = []
for mybook in mybooks:
df.append([mybook,os.path.basename(mybook)])
# Exchange ListObject to Dataframe
df = pd.DataFrame(df)
# Dump to ExcelFile
outputFilename = "filename.xlsx"
outputFolder = r"filepath"
outputFileFullpath = outputFolder + "\\" + outputFilename
df.to_excel(outputFileFullpath,'List')
print(
"The output of the file is finished.\n\n\n" +
"File output location:" + outputFolder + "\n" +
"file name:" + outputFilename
)
Recommended Posts