Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import shutil
- import glob
- import platform
- def clean_sims3_cache():
- """
- Cleans various cache files and folders for The Sims 3 to help resolve
- performance issues and other problems. This script should be placed in
- 'Documents\\Electronic Arts\\The Sims 3' folder.
- """
- if os.path.exists("DeviceConfig.log"):
- # Delete specific files
- files_to_delete = [
- "CASPartCache.package",
- "compositorCache.package",
- "scriptCache.package",
- "simCompositorCache.package",
- "socialCache.package",
- os.path.join("DCCache", "dcdb0.dbc"),
- os.path.join("DCCache", "missingdeps.idx"),
- ]
- for file_path in files_to_delete:
- try:
- if os.path.exists(file_path):
- os.remove(file_path)
- print(f"Deleted: {file_path}")
- except Exception as e:
- print(f"Error deleting {file_path}: {e}")
- # Delete files in Downloads, SigsCache, and Thumbnails folders
- folders_with_patterns = {
- "Downloads": "*.bin",
- "SigsCache": "*.bin",
- "Thumbnails": "*.package",
- }
- for folder, pattern in folders_with_patterns.items():
- full_pattern = os.path.join(folder, pattern)
- for file_path in glob.glob(full_pattern):
- try:
- os.remove(file_path)
- print(f"Deleted: {file_path}")
- except Exception as e:
- print(f"Error deleting {file_path}: {e}")
- # Handle FeaturedItems folder
- featured_items_path = "FeaturedItems"
- if os.path.exists(featured_items_path):
- try:
- # Delete all files in FeaturedItems
- for file_path in glob.glob(os.path.join(featured_items_path, "*")):
- os.remove(file_path)
- print(f"Deleted: {file_path}")
- # Remove the FeaturedItems directory
- os.rmdir(featured_items_path)
- print(f"Removed directory: {featured_items_path}")
- # Recreate FeaturedItems as an empty file
- with open(featured_items_path, "w") as f:
- pass
- print(f"Recreated {featured_items_path} as an empty file.")
- except Exception as e:
- print(f"Error handling {featured_items_path}: {e}")
- # Delete files in DCBackup, except ccmerged.package
- dc_backup_path = "DCBackup"
- for file_path in glob.glob(os.path.join(dc_backup_path, "*")):
- if os.path.basename(file_path).lower() != "ccmerged.package":
- try:
- os.remove(file_path)
- print(f"Deleted: {file_path}")
- except Exception as e:
- print(f"Error deleting {file_path}: {e}")
- # Delete xcpt*, ScriptError_*, and KW* files in the current directory
- for pattern in ["xcpt*", "ScriptError_*", "KW*"]:
- for file_path in glob.glob(pattern):
- try:
- os.remove(file_path)
- print(f"Deleted: {file_path}")
- except Exception as e:
- print(f"Error deleting {file_path}: {e}")
- # Delete files in WorldCaches folder, only on Windows
- if platform.system() == "Windows":
- world_caches_path = "WorldCaches"
- world_caches_pattern = os.path.join(world_caches_path, "*")
- for file_path in glob.glob(world_caches_pattern):
- try:
- os.remove(file_path)
- print(f"Deleted: {file_path}")
- except Exception as e:
- print(f"Error deleting {file_path}: {e}")
- else:
- print("Skipping WorldCaches cleanup. This is only done on Windows.")
- print("Cache cleaning complete.")
- else:
- print(
- "This file does not appear to be in the correct directory! "
- "Please place this file in your 'Documents\\Electronic Arts\\The Sims 3' folder."
- )
- input("Press Enter to exit.") # Equivalent of 'pause' in batch
- if __name__ == "__main__":
- clean_sims3_cache()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement