Windows 10 shortcut editor
If you have multiple shortcuts (.lnk, .url) pointing to the same location, but this location has changed, you want to be able to correct this location in bulk.
You can use the following PowerShell script:
https://gallery.technet.microsoft.com/scriptcenter/Modify-shortcut-file-lnk-fdfee592.
If you don't know if your shortcuts are .lnk files or .url files, issue the following command first:
Get-ChildItem -Path $folder -Filter $fileName -Recurse | Where-Object { $_.Attributes -ne "Directory"} | select -ExpandProperty FullName
Then adapt the .ps1 script accordingly:
#modify variables accordingly
$fileName ="*.url"
$folder = "D:\Favorites\Links\"
[string]$from = "oldsite.org"
[string]$to = "newsite.org"
$list = Get-ChildItem -Path $folder -Filter $fileName -Recurse | Where-Object { $_.Attributes -ne "Directory"} | select -ExpandProperty FullName
$obj = New-Object -ComObject WScript.Shell
ForEach($lnk in $list)
{
$obj = New-Object -ComObject WScript.Shell
$link = $obj.CreateShortcut($lnk)
[string]$path = $link.TargetPath
[string]$path = [string]$path.Replace($from.tostring(),$to.ToString())
#If you need workingdirectory change please uncomment the below line.
#$link.WorkingDirectory = [string]$WorkingDirectory.Replace($from.tostring(),$to.ToString())
#$link.Arguments = "-arguments"
$link.TargetPath = [string]$path
$link.Save()
}