Target for a folder full of links will be moved


  1. Posts : 14,046
    Windows 11 Pro X64 22H2 22621.1848
       #1

    Target for a folder full of links will be moved


    I have a folder that contains links to programs that reside in various other folders, called SysTools. I like to have the links for tools I use for various things in one place.

    I'm copying the SysTools folder to my Laptop and need to change all the Target drives from D:\..... to C:\.....
    Anyone know of a program that can do this in bulk or the Powershell command that could do this?

    If there were only a few I'd do it manually but there are over 70 so some automation would be nice.
      My Computers


  2. Posts : 14,046
    Windows 11 Pro X64 22H2 22621.1848
    Thread Starter
       #2

    I found some of what I need.

    Code:
    $shell = New-Object -COM WScript.Shell
    $targetPath = $shell.CreateShortcut($FullLinkPath).TargetPath
    This gets me the existing Target path when I give it the fully qualified path to the link.

    I think this will replace D:\ with C:\

    Code:
    $newtargetpath = "$targetpath" -replace 'D:\' C:\'
    Now how do I update the Target path in the original link?

    Would something like

    Code:
    $shell.TargetPath = $newtargetpath
    do the trick?
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 02:03.
Find Us




Windows 10 Forums