Created
March 20, 2025 00:28
-
-
Save haydenmc/67bd883235cd9d927144c642a569748c to your computer and use it in GitHub Desktop.
PowerShell script to search for files with names that won't work on an original Xbox FATX filesystem
This file contains 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
param ( | |
[Parameter(Position = 1)] | |
[ValidateScript({ Test-Path $_ -PathType Container })] # Ensures the provided folder path exists | |
[string] | |
$TargetDir | |
) | |
$maxLength = 42 | |
$invalidChars = '[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\#\$\%\&\''\(\)\-\.\@\[\]\^_`\{\}~ ]' | |
# Recursively get all files in the directory | |
Write-Host -ForegroundColor Cyan "Enumerating files in $((Get-Item -Path $TargetDir).FullName)..." | |
$files = Get-ChildItem -Path $TargetDir -Recurse -File -FollowSymlink | |
Write-Host -ForegroundColor Cyan "Checking $($files.Length) files..." | |
# Loop through each file and check its name | |
foreach ($file in $files) { | |
$fileName = $file.Name | |
# Check if file name is 42 or more characters long | |
if ($fileName.Length -gt $maxLength) { | |
Write-Output "Invalid length: $($fileName), Full Path: $($file.FullName)" | |
continue | |
} | |
# Check if file name contains only valid characters | |
if ($fileName -match $invalidChars) { | |
Write-Output "Invalid chars: $($fileName), Full Path: $($file.FullName)" | |
continue | |
} | |
} | |
Write-Host -ForegroundColor Green "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment