#!/usr/bin/env python3 """Fix PS3 PARAM.SFO 'Install Disc' titles with proper game names. Updates PARAM.SFO TITLE field for games showing 'Install Disc' to include the actual game name from the folder name. """ import struct import shutil from pathlib import Path from datetime import datetime def read_param_sfo(param_sfo_path): """Read PARAM.SFO file structure. Returns: tuple: (raw_data, entries_list) or (None, None) if invalid """ try: with open(param_sfo_path, 'rb') as f: data = bytearray(f.read()) # Check magic header if data[:4] != b'\x00PSF': return None, None # Parse header key_table_start = struct.unpack(' max_len: new_title = new_title[:max_len] # Update title in data new_title_bytes = new_title.encode('utf-8') value_start = title_entry['value_start'] # Clear old title area (fill with nulls) for i in range(title_entry['data_max_len']): data[value_start + i] = 0 # Write new title data[value_start:value_start + len(new_title_bytes)] = new_title_bytes # Update data_len in entry entry_offset = title_entry['entry_offset'] new_len = len(new_title_bytes) + 1 # +1 for null terminator struct.pack_into(' 0: print("=" * 70) print("To apply these changes, run with --apply flag") print("=" * 70) if __name__ == '__main__': main()