I am trying to sort/rename files that I automatically download from outlook. Each file comes from an athlete from one of three sports. Right now I have this loop able to sort the file into the correct folder based on the tuple but I was wondering if I can also make it rename the file at the same time based on the name in the tuple that identified where it should be sorted to.
source = r'C:\path\source\\'
dest1 = r'C:\path\dest1\\'
dest2 = r"C:\path\dest2\\"
dest3 = r"C:\path\dest3\\"
df_full_FB_roster = pd.read_csv('Full_FB_Roster.csv')
fullfb = df_full_FB_roster['name'].unique()
set(fullfb)
df_full_tennis_roster = pd.read_csv('Full_tennis_Roster.csv')
fulltennis = df_full_tennis_roster['name'].unique()
set(fulltennis)
df_full_bowling_roster = pd.read_csv('Full_bowling_Roster.csv')
fullfb = df_full_bowling_roster['name'].unique()
set(fullbowling)
files = os.listdir(source)
for f in files:
if (f.startswith(tuple(fullfb))):
shutil.move(source + f, dest1 + f)
elif (f.startswith(tuple(fulltennis))):
shutil.move(source + f, dest2 + f)
elif (f.startswith(tuple(fullbowling))):
shutil.move(source + f, dest3 + f)