How To Batch Change Drive Letters In Windows Shortcuts
Published by Stephen Milward in Science And Technology · Friday 23 Oct 2026 · 3 minutes
Tags: batch, change, drive, letters, Windows, shortcuts, how, to, guide, tutorial, script, Powershell
Tags: batch, change, drive, letters, Windows, shortcuts, how, to, guide, tutorial, script, Powershell
Everyone gets frustrated at times in their computing experience. Everything from annoying little issues to system breaking emergencies, one thing can be guaranteed - the answer to the problem is out there, somewhere.
To put my issue in context, it's to do with:
- Windows shortcuts
- Changing the drive letter in the 'Target' and 'Start in' fields
- Making the changes for thousands of shortcuts at once
I wanted to move files from a slow NAS (the S:\ drive) to a faster one (the T:\ drive), keeping the folder structure the same. Moving the files is easy, but clearly that broke the shortcuts that pointed to the S:\ drive. Annoying.
What's more annoying is that Microsoft do not provide a tool to edit the shortcut fields in a batch. You can do it one at a time, but I've thousands of shortcuts, and a life. Time to be creative.
The way I've done the drive letter changes is to use a PowerShell (i) script. If you decide to use this script, YOU MUST MAKE BACKUPS BEFOREHAND. I can say that this worked for me, but don't blame me if it doesn't work for you and you didn't make backups first. Frankly, that makes you the stupid one.
In the script below, I've used my S:\ and T:\ drive letters, since that's all I wanted to change in the shortcut fields. You can use whatever your changes require.
Method:
- Paste the script into PowerShell ISE.
- Update the , , and values to match your network structure.
- Run the script with = and read the yellow text console output to verify the mapping logic is correct. No changes are made at this point. If you're happy, edit the script to read = and run it once more to perform the bulk update, keeping the changes.
- Test new shortcuts.
powershell= "C:\Path\To\Your\Shortcuts" # Location where your .lnk files are saved= "S:\" # Include the backslash= "T:\" # Can be a new UNC path or another drive letter= # Set to to actually apply the changes= New-Object -ComObject WScript.Shell= Get-ChildItem -Path -Filter *.lnk -RecurseWrite-Host "--- STARTING SHORTCUT SCAN ---" -ForegroundColor Cyanif () {Write-Host "[PREVIEW MODE] No changes will be saved to disk." -ForegroundColor Yellow}foreach ( in ) {= .CreateShortcut(.FullName)# Check if the target path starts with the old drive letterif (.TargetPath.StartsWith(, [System.StringComparison]::OrdinalIgnoreCase)) {# Calculate what the new target and working directories will look like= [regex]::Replace(.TargetPath, "^" + [regex]::Escape(), , [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)= ""if (.WorkingDirectory.StartsWith(, [System.StringComparison]::OrdinalIgnoreCase)) {= [regex]::Replace(.WorkingDirectory, "^" + [regex]::Escape(), , [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)}# Handle the action based on simulation settingsif () {Write-Host "[WOULD UPDATE] File: $(.Name)" -ForegroundColor YellowWrite-Host " Old Target: $(.TargetPath)"Write-Host " New Target: "if () {Write-Host " Old StartIn: $(.WorkingDirectory)"Write-Host " New StartIn: "}Write-Host ""} else {# Apply the changes for real.TargetPath =if () {.WorkingDirectory =}.Save()Write-Host "[UPDATED] $(.Name)" -ForegroundColor Green}}}Write-Host "--- SCAN COMPLETE ---" -ForegroundColor CyanUse code with caution.
I hope that this works for you. It's certainly worked here and made my computing life a lot easier.
(i) Wikipedia: PowerShell
