Last active
September 12, 2026 15:32
-
-
Save 5j9/662b22633a30695e9f732cc189d7b258 to your computer and use it in GitHub Desktop.
Project Zomboid Copy map_sand.bin To Another Save
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import shutil | |
| from pathlib import Path | |
| # ============================================================ | |
| # CONFIGURATION | |
| # ============================================================ | |
| SAVES_DIR = Path(r'C:\Users\a\Zomboid\Saves\Sandbox') | |
| # ============================================================ | |
| # SCRIPT | |
| # ============================================================ | |
| def main(): | |
| print('Project Zomboid B42 - Copy Sandbox Settings') | |
| print('=' * 60) | |
| print() | |
| if not SAVES_DIR.exists(): | |
| print('ERROR: Saves directory not found:') | |
| print(SAVES_DIR) | |
| return | |
| # Find save directories | |
| saves = sorted( | |
| [p for p in SAVES_DIR.iterdir() if p.is_dir()], key=lambda p: p.name | |
| ) | |
| if not saves: | |
| print('No saves found.') | |
| return | |
| print('Available saves:') | |
| print() | |
| for i, save in enumerate(saves, 1): | |
| print(f' [{i}] {save.name}') | |
| print() | |
| # Source save | |
| while True: | |
| try: | |
| source_num = int(input('Select NEW save (source): ')) | |
| if 1 <= source_num <= len(saves): | |
| break | |
| except ValueError: | |
| pass | |
| print('Invalid selection.') | |
| source = saves[source_num - 1] | |
| # Destination save | |
| while True: | |
| try: | |
| destination_num = int(input('Select OLD save (destination): ')) | |
| if 1 <= destination_num <= len(saves): | |
| break | |
| except ValueError: | |
| pass | |
| print('Invalid selection.') | |
| destination = saves[destination_num - 1] | |
| print() | |
| print('Source :', source.name) | |
| print('Destination :', destination.name) | |
| print() | |
| if source == destination: | |
| print('ERROR: Source and destination are the same save.') | |
| return | |
| source_file = source / 'map_sand.bin' | |
| destination_file = destination / 'map_sand.bin' | |
| if not source_file.exists(): | |
| print('ERROR: Source map_sand.bin does not exist.') | |
| print(source_file) | |
| return | |
| if not destination_file.exists(): | |
| print('ERROR: Destination map_sand.bin does not exist.') | |
| print(destination_file) | |
| return | |
| # Backup destination before replacing it | |
| backup_file = destination / 'map_sand.bin.before_copy' | |
| print('Creating backup:') | |
| print(' ', backup_file) | |
| shutil.copy2(destination_file, backup_file) | |
| # Copy generated sandbox file | |
| shutil.copy2(source_file, destination_file) | |
| print() | |
| print('SUCCESS') | |
| print('=' * 60) | |
| print('Copied:') | |
| print(f' {source_file}') | |
| print() | |
| print('To:') | |
| print(f' {destination_file}') | |
| print() | |
| print('Original destination backed up as:') | |
| print(f' {backup_file}') | |
| print() | |
| print('You can now load the destination save.') | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment