if Path(file).is_dir():
new_path = folder_track + '/Folders/' + filename
os.rename(file, new_path)
elif Path(file).suffix in audio_extensions:
new_path = folder_track + '/Audio/' + filename
os.rename(file, new_path)
elif Path(file).suffix in photo_extensions:
new_path = folder_track + '/Photos/' + filename
os.rename(file, new_path)
elif Path(file).suffix in archive_extensions:
new_path = folder_track + '/Archives/' + filename
os.rename(file, new_path)
elif Path(file).suffix in application_extensions:
new_path = folder_track + '/Applications/' + filename
os.rename(file, new_path)
elif Path(file).suffix in video_extensions:
new_path = folder_track + '/Videos/' + filename
os.rename(file, new_path)
else:
new_path = folder_track + '/Other/' + filename
os.rename(file, new_path)
os.rename(file, new_path)
suffixes = {'Audio': ['.mp3', '.wav'], 'Photos': ['.jpg', '.png'], etc, etc}
suffix = Path(file).suffix
for folder_name, extensions in suffixes.items():
if suffix in extensions:
new_path = f'{folder_track}/{folder_name}/{filename}'
break
else:
new_path = f'{folder_track}/Other/{filename}'
os.rename(file, new_path)