I have .xls files in a directory that i need to move to another directory and renamed. Those files are updated monthly and will have a different name each month. For instance the current name is Geocortex Applications - Asset Capture - Sessions By Visitor Type (10_01_2018 - 10_06_2019).csv and next month it will be Geocortex Applications - Asset Capture - Sessions By Visitor Type (10_01_2018 - 11_06_2019).csv There are several of these files each with different names between the - - but the formatting is the same, see the image below.
screen shot of folder
Each month i need those files moved to another folder and given the name that is between the - -. For instance this one would need to be renamed 'Asset Capture.xls'.
My python experience is limited...so far i've only used python within ESRI products using Arcpy. Any help that can be given is greatly appreciated.
below is what i've done. I can move a rename a single file but i need it to cycle through all xls and rename with the name between the - - in the file name.
import shutilimport osos.chdir(r'C:\Users\learly\Downloads')renFolder= (r'C:\Users\learly\Downloads\renamed')oldname = 'Geocortex Applications - Asset Capture - Sessions By Visitor Type
(10_01_2018 - 10_06_2019).csv'newname= 'renTest.csv'shutil.move(oldname, renFolder+'/'+newname)