Created
February 3, 2026 03:29
-
-
Save LuckedCoronet/ee68b978c088ef5ebc95b31185b60672 to your computer and use it in GitHub Desktop.
PowerShell script that creates junction links for Minecraft Bedrock data directories (com.mojang)
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
| <# | |
| .SYNOPSIS | |
| Creates junction links for Minecraft Bedrock data directories (com.mojang). | |
| .DESCRIPTION | |
| Creates a directory that will contain junction links to commonly accessed | |
| Minecraft Bedrock data directories (resource_packs, minecraftWorlds, etc). | |
| .PARAMETER DestinationPath | |
| Target directory to contain links. | |
| .PARAMETER MinecraftDataPath | |
| Source Minecraft Bedrock directory in AppData. | |
| Default: "$env:APPDATA\Minecraft Bedrock" | |
| .PARAMETER Force | |
| Whether to overwrite the destination path if it already exists. | |
| .EXAMPLE | |
| .\mc-link.ps1 -DestinationPath .\com.mojang | |
| #> | |
| param ( | |
| [Parameter(Mandatory = $true)] | |
| [string]$DestinationPath, | |
| [string]$MinecraftDataPath = "$env:APPDATA\Minecraft Bedrock", | |
| [switch]$Force | |
| ) | |
| $DestinationPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($DestinationPath) | |
| $MinecraftDataPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($MinecraftDataPath) | |
| if (-not (Test-Path $MinecraftDataPath)) { | |
| Write-Error "Minecraft Bedrock directory not found at $MinecraftDataPath" | |
| exit 1 | |
| } | |
| if (Test-Path $DestinationPath) { | |
| if ($Force) { | |
| Remove-Item $DestinationPath -Recurse -Force | |
| Write-Host "Removed existing destination." | |
| } | |
| else { | |
| Write-Error "Path '$DestinationPath' already exists. Use -Force to overwrite." | |
| exit 1 | |
| } | |
| } | |
| New-Item -Path $DestinationPath -ItemType Directory -Force | Out-Null | |
| # Resolve com.mojang | |
| $UsersPath = Join-Path $MinecraftDataPath "Users" | |
| $ComMojangShared = Join-Path $UsersPath "Shared\games\com.mojang" | |
| if (-not (Test-Path $ComMojangShared)) { | |
| Write-Error "Shared com.mojang directory not found at $ComMojangShared" | |
| exit 1 | |
| } | |
| $UniqueUserPath = Get-ChildItem $UsersPath -Directory | | |
| Where-Object { $_.Name -match '^\d+$' } | | |
| Sort-Object Name | | |
| Select-Object -Last 1 | |
| if (-not $UniqueUserPath) { | |
| Write-Error "No unique user data directories found in $UsersPath" | |
| exit 1 | |
| } | |
| $ComMojangUnique = Join-Path $UniqueUserPath.FullName "games\com.mojang" | |
| if (-not (Test-Path $ComMojangUnique)) { | |
| Write-Error "Unique com.mojang directory not found at $ComMojangUnique" | |
| exit 1 | |
| } | |
| # Create links | |
| $Links = @( | |
| @{ Source = "$ComMojangShared\behavior_packs"; Name = "behavior_packs" } | |
| @{ Source = "$ComMojangShared\development_behavior_packs"; Name = "development_behavior_packs" } | |
| @{ Source = "$ComMojangShared\development_resource_packs"; Name = "development_resource_packs" } | |
| @{ Source = "$ComMojangShared\development_skin_packs"; Name = "development_skin_packs" } | |
| @{ Source = "$ComMojangShared\resource_packs"; Name = "resource_packs" } | |
| @{ Source = "$ComMojangUnique\custom_skins"; Name = "custom_skins" } | |
| @{ Source = "$ComMojangUnique\minecraftpe"; Name = "minecraftpe" } | |
| @{ Source = "$ComMojangUnique\minecraftWorlds"; Name = "minecraftWorlds" } | |
| @{ Source = "$ComMojangUnique\Screenshots"; Name = "Screenshots" } | |
| @{ Source = "$ComMojangUnique\skin_packs"; Name = "skin_packs" } | |
| @{ Source = "$ComMojangUnique\world_templates"; Name = "world_templates" } | |
| @{ Source = "$MinecraftDataPath\logs"; Name = "logs" } | |
| @{ Source = "$MinecraftDataPath\premium_cache"; Name = "premium_cache" } | |
| @{ Source = "$MinecraftDataPath\treatments"; Name = "treatments" } | |
| ) | |
| Write-Host "Linking directories from $MinecraftDataPath..." | |
| foreach ($Link in $Links) { | |
| if (Test-Path $Link.Source) { | |
| $DestFile = Join-Path $DestinationPath $Link.Name | |
| New-Item -ItemType Junction -Path $DestFile -Value $Link.Source | Out-Null | |
| Write-Host "Linked: $($Link.Name)" | |
| } | |
| else { | |
| Write-Warning "Skipping: $($Link.Name) (source not found)" | |
| } | |
| } | |
| Write-Host "Done." -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment