# ROM Organizer A comprehensive ROM management and organization toolkit for retro gaming enthusiasts and emulation setups. ## Overview ROM Organizer is a collection of bash scripts designed to automate the process of downloading, filtering, organizing, and preparing ROM collections for various retro gaming systems. The project supports dozens of gaming platforms from the 1970s through the 2000s, with specialized scripts for different regions and "1G1R" (One Game One ROM) setups. ## Features - **Multi-Platform Support**: Build scripts for 30+ gaming systems including: - Classic consoles (Atari 2600/5200/7800, NES, SNES, Genesis/Mega Drive) - Handheld systems (Game Boy family, Game Gear, Lynx, Neo Geo Pocket) - Modern retro (3DS, PSP, Dreamcast, Saturn) - And many more - **Region-Specific Filtering**: Support for USA, English, and All-region ROM sets - **1G1R Optimization**: "One Game One ROM" filtering to eliminate duplicates - **Smart Organization**: Three-tier organization system - **Physical Organization**: Organize by region and kind (moves files) - **Virtual Organization**: Create language folders with symlinks (no duplication) - **On-Demand Folders**: Only create folders when ROMs exist for that category - **Automated Pipeline**: Source → Filter → Organize workflow - **Format Conversion**: Scripts for converting between archive formats (ZIP, CHD, ISO) - **Verification Tools**: ROM integrity checking and cleanup utilities - **Archive Maintenance**: Comprehensive tools for managing ROM archive collections: - Corruption detection and testing for ZIP, 7Z, RAR, TAR, and compressed files - Case-insensitive filename collision detection (Windows/FAT32 compatibility) - Parallel processing for faster scanning of large collections - Interactive cleanup with batch operations - Smart alphabetical grouping for optimal directory organization ## Project Structure ``` rom-groomer/ ├── bin/ # User-facing script symlinks (add to PATH) ├── builders/ # ROM set build scripts ├── converters/ # File format conversion scripts ├── core/ # Essential shared libraries and configuration ├── docs/ # Documentation and guides ├── examples/ # Example configurations and usage ├── organizers/ # ROM organization and management scripts ├── systems/ # System-specific configurations ├── tests/ # Test scripts and coverage analysis ├── tools/ # Utility scripts and helper tools ├── archive/ # Legacy files and documentation ├── LICENSE # Project license ├── README.md # Main project documentation └── STRUCTURE.md # Detailed structure documentation ``` For detailed information about each directory and its contents, see [STRUCTURE.md](STRUCTURE.md). ## Quick Start 1. **Setup**: Run the setup wizard to configure your environment ```bash ./bin/setup-wizard.sh ``` 2. **Configure**: The wizard will guide you through setting up paths and preferences 3. **Pre-flight Check**: Validate your setup ```bash ./bin/preflight-checks.sh ``` 4. **Select Platform**: Run the appropriate build script ```bash ./builders/build-nes-usa-1g1r.sh # No-Intro: Nintendo Entertainment System ./builders/build-saturn-eng-1g1r.sh # Redump: Sega Saturn ``` 5. **Organize**: Sort and structure your collections ```bash ./bin/organize-roms.sh /path/to/roms --region ``` ## Installation and Setup ### Add to PATH (Recommended) For easy access to common scripts, add the `bin/` directory to your PATH: ```bash # Add to your ~/.bashrc or ~/.profile export PATH="/path/to/rom-groomer/bin:$PATH" # Or create a one-time alias alias rom-groomer="/path/to/rom-groomer/bin" ``` With the bin directory in your PATH, you can run common scripts from anywhere: ```bash setup-wizard.sh # Interactive setup organize-roms.sh /path/to/roms # Organize collection sort2folders.sh /path/to/roms # Sort into folders convertFromZipCueToOggCue.sh *.zip # Convert audio ``` ### Manual Execution You can also run scripts directly from their respective directories: ```bash ./tools/setup-wizard.sh ./organizers/organize-roms.sh /path/to/roms ./converters/convertFromZipCueToOggCue.sh input.zip ``` ## Core Scripts Overview ### Organizers - `organize-roms.sh` - **Advanced ROM organization system** - Organize by region (physical move to `By Region/` folders) - Organize by kind (physical move special editions like Beta, Proto, etc.) - Organize by language (virtual symlinks to `By Language/` folders) - Configure via environment variables (see [docs/BUILD-SCRIPT-CONFIGURATION.md](docs/BUILD-SCRIPT-CONFIGURATION.md)) - Three build types: USA (USA-only), ENG (English international), ALL (all languages) - `sort2folders.sh` - Smart alphabetical grouping utility - `unzipfiles.sh` - Extract archives with summary reporting ### Converters - `convertFromZipCueToOggCue.sh` - Convert ZIP+CUE to OGG+CUE - `convertFromZipCueToFlacCue.sh` - Convert ZIP+CUE to FLAC+CUE - `convertFromZipCueToChd.sh` - Convert ZIP+CUE to CHD format ### Tools - `setup-wizard.sh` - Interactive first-time setup - `preflight-checks.sh` - System dependency validation - `scan-archives.sh` - Archive integrity and maintenance ### Builders - `build-{system}-{region}-1g1r.sh` - ROM set builders for specific systems ## Archive Maintenance Tools The project includes specialized tools for maintaining clean, organized ROM collections: ### sort2folders.sh - Smart Directory Organization Automatically organizes large ROM collections into alphabetically grouped subdirectories with intelligent sub-letter splitting: ```bash ./sort2folders.sh /path/to/roms/ # Organize into A-Z folders ./sort2folders.sh /path/to/roms/ --group-size 500 # Custom grouping size ./sort2folders.sh /path/to/roms/ --dry-run # Preview changes ``` **Features:** - Smart alphabetical grouping (A-C, D-F, etc.) - Sub-letter splitting for large collections (Ba-Bl, Bm-Bz) - Handles special characters and non-alphabetic names - Tested with collections of 5,000+ ROMs - Dry-run mode for safe preview ### scan-archives.sh - Archive Integrity and Compatibility Comprehensive tool for identifying and fixing problematic archive files in ROM collections: ```bash ./scan-archives.sh /path/to/roms/ # Scan only ./scan-archives.sh /path/to/roms/ --fix-collisions # Fix filename collisions ./scan-archives.sh /path/to/roms/ --remove-corrupted # Remove corrupted files ./scan-archives.sh /path/to/roms/ --parallel 8 # Use 8 parallel jobs ./scan-archives.sh /path/to/roms/ --dry-run # Preview without changes ``` **Features:** - Tests archive integrity for ZIP, 7Z, RAR, TAR, and compressed formats - Detects case-insensitive filename collisions (Windows/FAT32 compatibility issues) - Parallel processing (1-8 jobs) for faster scanning of large collections - Interactive deletion prompts with detailed file information - Comprehensive logging and reporting - Support for compound extensions (.tar.gz, .tar.bz2, etc.) **Archive Format Support:** - ZIP files (.zip) - using unzip - 7-Zip archives (.7z) - using 7z - RAR archives (.rar) - using unrar - TAR archives (.tar, .tar.gz, .tar.bz2, .tar.xz) - using tar - Compressed files (.gz, .bz2, .xz, .lz, .lzma, .z) - using respective tools ### verify-and-clean-roms-zips.sh - ROM-Specific DAT Validation Specialized tool for validating ROM ZIP files against DAT file specifications: ```bash ./verify-and-clean-roms-zips.sh # Validate ROMs against DAT ``` **Features:** - Validates ROM ZIP files against No-Intro/Redump DAT files - Performs MD5 and SHA1 hash verification for ROM authenticity - Automatically deletes ZIPs that don't contain valid ROMs - Removes files with hash mismatches (corrupted or incorrect ROMs) - XML-based DAT file parsing using xmlstarlet - Designed specifically for ROM collection validation **Use Cases:** - Cleaning ROM collections after downloads or transfers - Verifying ROM authenticity against known-good databases - Removing invalid or corrupted ROM files from collections - Ensuring ROM collections match DAT file specifications **Comparison with scan-archives.sh:** - **scan-archives.sh**: General archive maintenance (corruption detection, filename collisions) - **verify-and-clean-roms-zips.sh**: ROM-specific validation (DAT compliance, hash verification) ## ROM Organization System The ROM Groomer includes an advanced three-tier organization system that intelligently structures ROM collections: ### Three Organization Tiers #### 1. Physical Organization - Regions - **Moves** ROM files to `By Region//` folders - Organizes by USA, Europe, Japan, World, etc. - Configurable via `KEEP_IN_ROOT_REGIONS` (keep specified regions in root) - Example: USA and World games stay accessible in root folder #### 2. Physical Organization - Kinds - **Moves** special editions to kind subfolders (recursive) - Organizes Beta, Proto, Demo, Virtual Console, etc. - Configurable via `KEEP_IN_ROOT_KINDS` (don't organize specified kinds) - Works in both root and region subfolders #### 3. Virtual Organization - Languages - **Creates symlinks** to `By Language//` folders - No file duplication (symlinks only) - Multi-language ROMs appear in multiple folders - Configurable via `ORGANIZE_LANGUAGES_BY_SYMLINK` and `LANGUAGE_EXCLUDE_REGIONS` ### Build Configurations **USA 1G1R Build** (USA games only): ```bash export KEEP_IN_ROOT_REGIONS="USA,World" export KEEP_IN_ROOT_KINDS="" export ORGANIZE_LANGUAGES_BY_SYMLINK="false" export LANGUAGE_EXCLUDE_REGIONS="" ``` **English 1G1R Build** (USA + international English): ```bash export KEEP_IN_ROOT_REGIONS="USA,World" export KEEP_IN_ROOT_KINDS="" export ORGANIZE_LANGUAGES_BY_SYMLINK="true" export LANGUAGE_EXCLUDE_REGIONS="USA,World" # Prevent USA games from cluttering English folder ``` **All Languages Build** (complete language browsing): ```bash export KEEP_IN_ROOT_REGIONS="USA,World" export KEEP_IN_ROOT_KINDS="" export ORGANIZE_LANGUAGES_BY_SYMLINK="true" export LANGUAGE_EXCLUDE_REGIONS="" ``` ### Key Features - **On-Demand Folder Creation**: Only creates folders when ROMs exist for that category - **Relative Symlinks**: Portable across different mount points - **Multi-Language Support**: Single ROM appears in multiple language folders - **USA Exclusion**: Keep 500+ USA games out of English folder (they're in root already) - **Recursive Kind Organization**: Organizes special editions in root and region subfolders ### Documentation - [BUILD-SCRIPT-CONFIGURATION.md](docs/BUILD-SCRIPT-CONFIGURATION.md) - Complete configuration guide - [LANGUAGE-SYMLINK-IMPLEMENTATION.md](docs/LANGUAGE-SYMLINK-IMPLEMENTATION.md) - Technical implementation - [ORGANIZATION-VISUAL-COMPARISON.md](docs/ORGANIZATION-VISUAL-COMPARISON.md) - Visual examples - [test-language-symlinks.sh](tests/test-language-symlinks.sh) - Comprehensive test suite (31 tests, all passing) ## Testing The project includes a comprehensive test suite to ensure reliability: ```bash ./run-tests.sh # Run complete test suite ./test-utils.sh # Test utility functions ./test-integration.sh # Test end-to-end workflows ``` Current test coverage: 50% success rate (7/14 suites passing) with comprehensive security validation and ongoing improvements. ## Supported Systems ### Nintendo Systems - NES, SNES, Nintendo 64, Game Boy (Color/Advance), Nintendo DS, 3DS ### Sega Systems - Master System, Genesis/Mega Drive, Sega CD, 32X, Saturn, Dreamcast, Game Gear ### Atari Systems - 2600, 5200, 7800, Jaguar, Lynx ### Sony Systems - PlayStation (PSX), PSP, PSP Minis ### Other Systems - 3DO, Neo Geo Pocket (Color), PC Engine/TurboGrafx, ColecoVision, Vectrex, Virtual Boy ## Pipeline Workflow The ROM organization process follows an 11-step workflow with comprehensive error handling and pre-flight validation for thorough ROM collection management: ### High-Level Pipeline 1. **Source** (`/source`): Raw ROM files and archives from myrient and extra sources 2. **Filter** (`/filter`): Platform and region filtering with ROM Manager 3. **Organization** (`/org`): Final organized ROM collections with language/region subdirectories 4. **Stage** (`/stage`): Staged collections ready for deployment 5. **Share** (`/share`): Final collections ready for distribution ### Detailed Workflow Steps 1. **Step 1 - Copy Source to Filter**: Copy raw ROMs from source directory to filter directory 2. **Step 2 - Filter ROMs**: Manual filtering using ROM Manager to select desired ROMs based on DAT files 3. **Step 3 - Delete Problematic ROMs**: Remove problematic ROMs using list files (delimiter: `-`) 4. **Step 4 - Copy Filtered to Organization**: Copy cleaned, filtered ROMs to organization directory 5. **Step 5 - System-Specific Commands**: Execute any platform-specific processing commands 6. **Step 6 - Organize into Subdirectories**: Intelligent ROM organization with three-tier system - **Physical Organization (Region)**: Move ROMs to `By Region/` folders (respects `KEEP_IN_ROOT_REGIONS`) - **Physical Organization (Kind)**: Move special editions to kind folders (respects `KEEP_IN_ROOT_KINDS`) - **Virtual Organization (Language)**: Create `By Language/` symlink folders (controlled by `ORGANIZE_LANGUAGES_BY_SYMLINK`) - See [Build Script Configuration](docs/BUILD-SCRIPT-CONFIGURATION.md) for details 7. **Step 7 - Add Extra Games**: Add additional ROMs from two sources: - **Myrient source** (delimiter: `+`): Additional games from the main myrient archive - **Extra directory** (delimiter: `.`): Custom ROMs like homebrew, hacks, or translations 8. **Step 8 - Copy to Stage**: Copy organized collections to staging directory 9. **Step 9 - Set ROM Link**: Create symbolic link pointing to staged collections 10. **Step 10 - Run AARM**: Generate metadata using AARM (Automated Asset and ROM Manager) 11. **Step 11 - Copy to Share**: Copy finalized collections to share directory for distribution ### List File Delimiters The system uses different delimiters in list filenames to determine processing behavior: - **`-` (minus)**: Delete ROMs listed in the file (e.g., `nes-Problematic-Games`) - **`+` (plus)**: Add ROMs from myrient source directory (e.g., `nes+Best-Games`) - **`.` (dot)**: Add ROMs from extra directory (e.g., `sega32x.Best-Games`) ## Dependencies - bash (4.0+) - Standard UNIX utilities (find, sort, uniq, etc.) - Optional: rclone (for remote ROM sources) - Optional: 7zip (for archive handling) The system includes pre-flight checks that automatically validate all dependencies before processing. ## Documentation This project includes comprehensive documentation: - **[README.md](README.md)** - Project overview and quick start guide (this file) - **[SCRIPTS.md](SCRIPTS.md)** - Complete reference for all 98+ scripts in the project - **[CONTRIBUTING.md](CONTRIBUTING.md)** - Development guidelines, project context, and AI assistant instructions - **[ROADMAP.md](ROADMAP.md)** - Development roadmap, planned features, and project priorities - **[ARCHITECTURE.md](ARCHITECTURE.md)** - System design and technical architecture details - **[CHANGELOG.md](CHANGELOG.md)** - Version history and changelog - **[PRIORITY_FIXES_FINAL_REPORT.md](PRIORITY_FIXES_FINAL_REPORT.md)** - Recent implementation status and improvements ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines and project context. ## License This project is intended for personal use with legally obtained ROM files. Users are responsible for ensuring compliance with copyright laws in their jurisdiction. ## Project Status Active development - see [ROADMAP.md](ROADMAP.md) for planned features and improvements.