Organize-MIG.ps1 is a PowerShell script designed to organize Nintendo Switch [.xci] game files, their associated [.bin] files, and any extracted folders into neatly named folders. Each game gets its own folder ending in [.xci], making your library easy to browse and manage.
The script safely handles filenames with special characters ([ ] and ( )) and avoids errors caused by moving folders into themselves.
How It Works
The Script
How to Use
Watch the console for progress messages. After completion, each game will be neatly organized into its own [.xci] folder.
Caution: Any Games that have "+" characters in them may act odd. It will list the ones at the end it tried to rename. You may want to double check those if you need the folder and game files to be identical to the XCI name. It's a small bug, but it is a rare occurrence and not sure how to fix just yet.
Notes
The script safely handles filenames with special characters ([ ] and ( )) and avoids errors caused by moving folders into themselves.
How It Works
- Scans the folder where the script resides (or the current location if run line-by-line).
- Finds all [.xci] files in the folder.
- Extracts the clean game title from each [.xci] filename.
- Creates a folder for each game, named <Game Name>.xci.
- Moves the following into the corresponding folder:
- The main [.xci] file
- All [.bin] files that start with the game name
- Any existing folders that start with the game name, excluding the target folder itself
- Outputs progress messages to the console for each game processed.
The Script
Code:
$Root = $PSScriptRoot
if (-not $Root) { $Root = Get-Location }
# 1. Grab only the actual .xci FILES
$XciFiles = Get-ChildItem -Path $Root -Filter *.xci -File
foreach ($xci in $XciFiles) {
$originalName = $xci.Name
$folderPath = Join-Path $Root $originalName
Write-Host "Processing: $originalName" -ForegroundColor Cyan
# 2. Check if the FOLDER already exists
if (Test-Path -LiteralPath $folderPath -PathType Container) {
Write-Host "Folder already exists, moving files in..." -ForegroundColor Gray
} else {
# RENAME the file temporarily to clear the path for the folder
$tempName = "$originalName.tmp"
Rename-Item -LiteralPath $xci.FullName -NewName $tempName
# Now create the folder
New-Item -ItemType Directory -Path $folderPath | Out-Null
# Move the temp file into the folder and rename it back
$tempFullPath = Join-Path $Root $tempName
Move-Item -LiteralPath $tempFullPath -Destination (Join-Path $folderPath $originalName) -Force
}
# 3. Handle the matching .bin files
# Get the prefix (everything before the first bracket)
$gameTitle = ($xci.BaseName -split '[\[\(]')[0].Trim()
# Move all .bin files that start with the game title
Get-ChildItem -Path $Root -Filter "$gameTitle*.bin" -File | ForEach-Object {
# Ensure we aren't trying to move the folder itself
if ($_.FullName -ne $folderPath) {
Move-Item -LiteralPath $_.FullName -Destination $folderPath -Force
}
}
Write-Host "Successfully organized: $originalName" -ForegroundColor Green
}
Write-Host "`nAll files are now paired in their matching folders." -ForegroundColor Yellow
Write-Host "`nRunning filename and folder repair pass..." -ForegroundColor Yellow
# Find all folders that contain the broken " + " prefix
Get-ChildItem -Path $Root -Directory | Where-Object { $_.Name -match ' \+ ' } | ForEach-Object {
$oldFolder = $_
$fixedFolderName = ($oldFolder.Name -split ' \+ ', 2)[1]
$fixedFolderPath = Join-Path $Root $fixedFolderName
Write-Host "Fixing folder: $($oldFolder.Name)" -ForegroundColor Cyan
# Rename the folder
Rename-Item -LiteralPath $oldFolder.FullName -NewName $fixedFolderName
# Now fix files inside it
Get-ChildItem -Path $fixedFolderPath -File | Where-Object { $_.Name -match ' \+ ' } | ForEach-Object {
$fixedFileName = ($_.Name -split ' \+ ', 2)[1]
Write-Host " Fixing file: $($_.Name)" -ForegroundColor Gray
Rename-Item -LiteralPath $_.FullName -NewName $fixedFileName -Force
}
}
Write-Host "Repair pass complete. All injected prefixes removed." -ForegroundColor Green
How to Use
- Save the code above as "Organize-MIG.ps1" in the folder containing your [.xci] and [.bin] files.
- Open PowerShell and navigate to the folder, or run the script directly from the console.
- Set Policy for Script:
Code:Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
- Unblock Script
Code:Unblock-File .\Organize-MIG.ps1
- Run the script:
Code:.\Organize-MIG.ps1
Watch the console for progress messages. After completion, each game will be neatly organized into its own [.xci] folder.
Caution: Any Games that have "+" characters in them may act odd. It will list the ones at the end it tried to rename. You may want to double check those if you need the folder and game files to be identical to the XCI name. It's a small bug, but it is a rare occurrence and not sure how to fix just yet.
Notes
- Always test the script using copied files. While it has been tested and functions as intended, you are responsible for your own files.
- This script is not endorsed by Nintendo and is not intended to support piracy. It is provided for educational purposes only.
Last edited by YoNoid,






