python - Compare & Change File Name
In response to work needs write a python script for compare & change file name from excel file the script will compare field "servicetag" data in sheet "host" & file name Reference file (demo.xlsx)formate code import os , re , pandas # rename file count count = 0 # get script root path desdir=os.getcwd() # get xlsx file path datafile = input ( "xlsx file path \n " ) #load xlsx file data df = pandas.read_excel(datafile , sheet_name = 'host' ) df_df=pandas.DataFrame(df) for i in range ( len (df_df)): for file in os.listdir(desdir): if bool (re.search(df_df[ 'servicetag' ][i] , file)): #file name check if bool (re.search(df_df[ 'host' ][i] , file)): break ; else : count =count+ 1 os.rename(os.path.join(desdir , file) , os.path.join(desdir , df_df[ 'host' ][i]+ '-' +fi...