Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 11, 2016, 07:51:21 AM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: How to change hundreds of shortcuts... in a hurry  (Read 6417 times)

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,368
    • View Profile
    • Donate to Member
How to change hundreds of shortcuts... in a hurry
« on: August 17, 2008, 03:22:14 PM »
Background:
On one machine, I'd built up a comprehensive system of shortcuts pointing to a repository of documents.
I had renamed all of these shortcuts, and grouped them in ways that make sense to me.
All of the shortcuts (.lnk files) reside in one folder, or sub-folders thereof
Now I have moved the whole thing to another destination on a different machine.

Question:
Can anyone tell me a fast way to change the <drive>\<folder> portion of the
<drive>\<folder>\<filename> structure in a couple of hundred of these things?


So, suppose they all point to         G:\Library      (e.g. G:\Library\RefDoc1)
I want to cause them to point to      Q:\NewLibrary   (e.g. Q:\NewLibrary\RefDoc1)


Thanks for taking the time to read this!

« Last Edit: August 17, 2008, 03:24:22 PM by cranioscopical »

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,100
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #1 on: August 17, 2008, 05:06:57 PM »
Maybe it would be a smart idea to make a system and/or user variable in your Windows ENVironment and use that variable in the filename/path of every shortcut. When you want to move from one location to the other you only have to change the variable in the ENVironment. You could even make this user-based if you like that sort of thing  :)

However, this solution will require you to change each and every one of them by hand.

The only .lnk editor I could find has it origins in Russia:
http://linkchanger.c...emaker.qarchive.org/
Direct download link:
http://fcsoft.by.ru/...nger/LinkChanger.zip

Reading through its manual it seems this is what you are looking for.

Edit: Typo's removed
« Last Edit: August 17, 2008, 05:16:27 PM by Shades »

AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #2 on: August 17, 2008, 05:18:03 PM »
In your old machine, they all pointed to G:\Library, right?

So start out the same way in your new machine.  The targets are still in G:\Library, and the .lnk files, wherever they are, still point to G:\Library.

Make \NewLibrary on drive Q:.  Now just right drag&drop everything in G:\Library to Q:\NewLibrary, and select "move".  Or move the whole Library folder to Q:, and then rename it NewLibrary.

In either method, the .lnk files will update themselves, no?  (as long as you *move* the files, not copy them and delete the originals.)

SirSmiley

  • Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #3 on: August 17, 2008, 06:35:41 PM »
What Andy said should work if the target directory is the same path except for the drive. I really like Shades suggestion and have to make a note of that for my future use.

If the linkchanger app doesn't do it let me know as I can wip a vbscript file up in five or 10 minutes to do this. May do the script either way. ;)

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #4 on: August 17, 2008, 06:36:54 PM »
I think AHK [edit](or some scripting of any sort)[/edit]will have to come into play to solve this :)

Andy: I don't think the shortcuts update when you move the files.

Oh, just remembered something: soft/hard links might help.

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,368
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #5 on: August 17, 2008, 07:00:46 PM »
AndyM, Right drag and drop didn't change anything for me. The shortcuts still pointed to the original location.  That would have been a nice quick solution.  I've never found XP updating its shortcuts except by doing a big 'flashlight' search... is that what you meant?  I'm using XP  Pro if that makes a  difference.  (On days like today I want OS/2 back).

Shades, I'll try the link changer, looks to be a good answer.

I'm trying to fiddle with this between other demands to which I must return my attention.  I'll take another crack at this when next I can, so I'll post results... later. 

Thanks a lot for the help!!  :Thmbsup:




SirSmiley

  • Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #6 on: August 17, 2008, 07:05:10 PM »
Actually, I tested Andy's suggestion out, mind you on virtual drives but, it worked. Although, I moved the files first followed by the shortcut.

Will whip up a vbscript and post it.

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,368
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #7 on: August 17, 2008, 07:17:28 PM »
SirSmiley, Thank you for that kind thought BUT LinkChanger did what I need in seconds, which is all that I had!

I really had to stick my head round the door again to do this  :Thmbsup: :Thmbsup: :Thmbsup: before I head back to things I'd rather avoid  :)

Thanks to all!



SirSmiley

  • Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #8 on: August 17, 2008, 07:56:35 PM »
No problem.

Here's the script for anyone. Uses standard WSH regular expressions

'Basic folder recursion, recurse folder, enumerate files and folders
'http://www.visualbasicscript.com/m_47117/tm.htm

Option Explicit

' create FSO
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objShell : Set objShell = CreateObject("WScript.Shell")

Dim strPattern, strReplace

' Text String to search target path for
strPattern="G:\\Library"
' Text String to replace target path with
strReplace="Q:\\NewLibrary"

' Call Recursion First
' Path to Folder Holding your shortcuts
RecurseFolder "c:\temp"

Sub RecurseFolder(strFolderPath)
 ' get folder
 Dim objFolder : Set objFolder = objFSO.GetFolder(strFolderPath)

 ' On Error Resume Next
 Dim objFile
 For Each objFile In objFolder.Files
If objFSO.GetExtensionName(objFile.Path)="lnk" Then ChangeShortcut(objFile.Path)
        ' WScript.Echo "File: " & objFile.Name
 Next
 ' On Error Goto 0
 
 ' On Error Resume Next
 Dim objSubFolder
 ' loop through sub folders
 For Each objSubFolder In objFolder.SubFolders
        'WScript.Echo "Folder: " & objSubFolder.Name
         ' have the sub call itself sending the sub folder path
         RecurseFolder objSubFolder.Path
 Next
 ' On Error Goto 0
End Sub

Sub ChangeShortcut(oFile)
Dim regEx
Dim objLink, oTargetOld, oTargetNew
Set objLink = objShell.CreateShortcut(oFile)
oTargetOld=objLink.TargetPath
  Set regEx = New RegExp            ' Create regular expression.
  regEx.Pattern = strPattern            ' Set pattern.
  regEx.IgnoreCase = False            ' Make case insensitive.
  oTargetNew=regEx.Replace(oTargetOld, strReplace)   ' Make replacement.
  objLink.TargetPath=oTargetNew 
  objLink.Save
End Sub

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,368
    • View Profile
    • Donate to Member
Re: How to change hundreds of shortcuts... in a hurry
« Reply #9 on: August 18, 2008, 07:55:43 AM »

This entire topic is an example of DonationCoder at its best.

User has a problem.
User is pressed for time.
User needs a solution.

User posts initial request at 16:22
User has multiple, working solutions by 20:56

All responses are:
  • Helpful
  • Thoughtful
  • Inventive
  • Friendly

It is a privilege and a pleasure to be a member here!

 :Thmbsup: :Thmbsup: