import os
import shutil
def sort_files_by_category(source_directory, destination_directory):
file_types = {
'Images': ['.jpg', '.jpeg', '.png', '.gif'],
'Documents': ['.doc', '.docx', '.txt', '.pdf'],
'Videos': ['.mp4', '.avi', '.mov'],
'Music': ['.mp3', '.wav'],
'Others': []
}
for root, dirs, files in os.walk(source_directory):
for file in files:
file_extension = os.path.splitext(file)[1].lower()
for category, extensions in file_types.items():
if file_extension in extensions:
category_directory = os.path.join(destination_directory, category)
os.makedirs(category_directory, exist_ok=True)
source_path = os.path.join(root, file)
destination_path = os.path.join(category_directory, file)
shutil.move(source_path, destination_path)
def clear_cache():
os.system('del /F /Q %temp%')
os.system('del /F /Q %systemroot%\Prefetch')
def install_useful_programs(programs):
for program in programs:
os.system(f'choco install {program} -y')
def optimize_system():
os.system('sfc /scannow')
os.system('chkdsk /f /r')
sort_files_by_category('C:\\path\\to\\source\\directory', 'C:\\path\\to\\destination\\directory')
clear_cache()
optimize_system()