Welcome Guest.   Make a donation to an author on the site July 25, 2014, 05:20:05 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2011! Download 30+ custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1] 2 Next   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: DONE: Batch adjust shortcut targets  (Read 11712 times)
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« on: June 22, 2012, 05:26:55 PM »


Let's suppose we have thousands of shortcuts pointing to images (contour plots), with the images all grouped together in the particular folder:

C:\4\images\50501\

Partial list of the image files:

50501_20104_21901.png
50501_20104_21902.png
50501_20104_21903.png
50501_20104_22001.png
50501_20104_22002.png
50501_20104_22003.png
etc.

All the shortcuts -- one per image above -- are burried in carefully named and organized subfolders within the particular root folder:

C:\4\shortcuts\50501\...

Now suppose we decide for whatever reason that we want to move all the images to another folder:

C:\work\images\50501\

Notice that the "4" has changed to "work".

Now all the shortcut files pointing to the first folder need to be changed accordingly.

The shortcut-altering program should be 'recursive', as the shortcuts are buried in subdirectories within the main shortcut folder.  But the task is identical for each shortcut.... 

change

"C:\4\shortcuts\50501\(image file)"

to

"C:\work\shortcuts\50501\(image file)"


Anyone here interested in writing a program that can accomplish the task?  Seems this would be a useful program.  If one already exists, I haven't found it.

The solution we presently have is to recreate all the shortcuts from scratch.  Skwire's "File Punter" can do that nicely.  Perhaps, however, it might be appropriate to have a "Batch adjust shortcut targets" program.

Comments appreciated.

Thanks.

Nicholas Kormanik
nkormanik@gmail.com

Logged
skwire
Moderator
*****
Posts: 4,015



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #1 on: June 22, 2012, 05:36:00 PM »

You might as well simply use File Punter to regenerate the shortcuts.  It would actually cost more to read the current shortcut and generate a new one than to simply generate a new one.  Make sense?
Logged

kunkel321
Supporting Member
**
Posts: 382


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #2 on: June 22, 2012, 05:43:11 PM »

Could bulk re-create the LNKs via Ctrl+A (select all the images), then hold Alt and click-n-drag to bulk create shortcuts for each image file....   Unfortunately this would put them all into where ever you dropped them (you'd then have to re-create your directory tree).
Logged
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #3 on: June 22, 2012, 06:02:09 PM »


Yep, does make sense.

I actually need to replicate (but with tiny path-tweak) all the shortcuts 12 times.  12 huge folders of images in total.

The conundrum is..., File Punter has already created one great workable set of shortcuts.  All are perfect.  16110 of 'em.  Buried and organized nicely within the relevant shortcuts folder for the first set of images.

So I was hoping to simply copy the entire set of shortcuts 11 more times, and merely adjust the shortcuts (recursively) to point to the next image folder.

It's not really that I'm "moving" the first set of images.  I just used that as an understandable illustration.  What I'm actually doing is creating 11 more image sets, in addition to the first.  So will need sets of shortcuts for each set of images.  Since I have a perfect set of shortcuts for the first set of images, it does seem reasonable to use it again and again, if the path-tweak can be made for each of the additional 11 sets.

Set #1 Shortcuts --> Set #1 Images
Set #2 Shortcuts --> Set #2 Images
.
.
.
Set #12 Shortcuts --> Set #12 Images

But, too, does seem like a useful program to have available for the world.  No one seems to have come up with it yet.

Logged
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #4 on: June 22, 2012, 06:25:56 PM »


By the way, in addition to the path changing, the filename target changes as well.

What changes in the filename is the "50501" part, becoming "50502", for the second set of images.  And on and on.

Logged
skwire
Moderator
*****
Posts: 4,015



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: June 22, 2012, 06:38:28 PM »

Since I have a perfect set of shortcuts for the first set of images, it does seem reasonable to use it again and again, if the path-tweak can be made for each of the additional 11 sets.

But that's what I'm saying -- just use File Punter again and create the additional rules you need.  Why create an entirely new program when File Punter can already do what you want?

Based off of your other thread, I gave you two example RegEx rules necessary to create your folders.  So, with 11 image sets total, you'd only have to create 22 rules total to generate all your needed shortcuts.  Really, what could be easier?
Logged

nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #6 on: June 22, 2012, 06:50:13 PM »


What about the world lacking and needing "Batch adjust shortcut targets"???

Logged
4wd
Supporting Member
**
Posts: 3,262



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: June 23, 2012, 12:16:32 AM »

What about the world lacking and needing "Batch adjust shortcut targets"???

But what you are doing is copying the files with a new name to a new destination.

It would be easier to create a new shortcut.

Is the folder structure for the images and the shortcuts the same?

If so then try this: BSC (nothing to do with cows)



Instructions:

Honestly, do you really want some?

Oh OK, it creates shortcuts in the Destination directory of whatever files are in the Source directory complete with directory structure - Bulk Shortcut Creator.

And yes, that is a cow icon smiley

* BSC.7z (266.32 KB - downloaded 258 times.)
* BSM.7z (406.84 KB - downloaded 322 times.)
« Last Edit: July 23, 2012, 04:10:43 AM by 4wd » Logged

Four wheel drive: Helping you get stuck faster, harder, further from help...........and it's no different on this forum Evil
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #8 on: June 23, 2012, 01:27:27 AM »


BSC looks like a nice little copying program good to keep on hand.  Thanks.

The structure of the shortcuts within subdirectories is different from the "Image Pool."

The motivation behind focusing on shortcuts was to avoid having to copy the image files themselves, over and over and over again, to all sorts of locations.  Better to have a zillion shortcuts, paired up in various ways, all pointing to the repository of images.  Easier to mix and match shortcuts.

Let's assume I'll create just one single "Image Pool" folder.  All images bunched together.  Over 100,000 images.

There will be 12 major groups of images within that "Image Pool" folder: 50501, 50502, 50503, etc.

Using "File Punter" I was able to create 1 of 12 sets of shortcuts to certain of those images (50501s).  So I still have 11 more sets of shortcuts to create.

If only one "Image Pool"...  Then the only part of the shortcuts which will change would be the first part of the target file name.  The path would be identical:

...path\50501_20104_21901.png.lnk  (belongs to the first set of shortcuts)
...path\50502_20104_21901.png.lnk  (belongs to the second set of shortcuts)
...path\50503_20104_21901.png.lnk  (belongs to the third set of shortcuts)
...path\etc.

I wish I could simply use the perfect set of shortcuts already created (for the 50501 set), make the ONE CHARACTER TWEAK in each filenme, and use these for the second shortcut set.  And on and on.  Through all 12 sets.

Appears not so easy to "Batch adjust shortcut targets", unfortunately.

=====

By the way, another approach different from shortcuts might be to put the filenames into a database, and have the database do the pairing, mixing, matching of files.  But, alas, I have even less experience in that area.  At least pairing up shortcuts makes sense to me.

Logged
4wd
Supporting Member
**
Posts: 3,262



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #9 on: June 23, 2012, 02:42:57 AM »

OK, maybe this slightly modified version will get there:

Added:
  • Basic wildcard filter for file matching.
  • Option to output shortcuts to one directory.

So you should be able to put all your images in one directory, enter 50503*.* in the filter field and have a load of shortcuts for matching files created in another directory sans directory structure.

...so goes the theory.

Absolutely no error trapping or any of that kind of malarkey  - you put something stupid in the filter field it's your fault. smiley



See above for archive.

Added mouseover tooltips.
« Last Edit: July 09, 2012, 05:23:48 AM by 4wd » Logged

Four wheel drive: Helping you get stuck faster, harder, further from help...........and it's no different on this forum Evil
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #10 on: June 23, 2012, 03:15:15 AM »


I'll try it out, 4wd.  I appreciate your efforts.  Still have FolMon running on two computers, one to each side of me, chugging out images, so I'm monitoring the progress easily, thanks to you.

And Skwire, still creating shortcuts with File Punter on my main computer here.  One full set of 32,220 lines of commands has been running in File Punter for nearly two days.  But getting the job done.  At least I think so.

=====

Possible solution to the task at hand found:

http://networkadminkb.com...ge-shortcuts-utility.aspx

Place copy of all the perfect 50501 shortcuts into "shortcuts to be changed" folder.

Run from command line (or batchfile?):

>ChangeLNKs    /d=c:\shortcuts to be changed    /n=names.txt    /p=paths.txt

names.txt
50501;50502

paths.txt
50501;50502


This will create a set of shortcuts pointing to 50502 set of images.

Repeat process for rest of sets....  50503, 50504, etc.  12 sets.

I'll experiment with it more tomorrow.


Logged
skwire
Moderator
*****
Posts: 4,015



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #11 on: June 23, 2012, 08:16:20 AM »

One full set of 32,220 lines of commands has been running in File Punter for nearly two days.

Are you saying that you have 32,220 rules/entries in File Punter?  If so, why?
Logged

4wd
Supporting Member
**
Posts: 3,262



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #12 on: June 24, 2012, 01:33:35 AM »

OK, I was bored so I thought I'd have a play around and came up with BSM, (guess what that stands for).



It'll modify shortcuts according to the regex entered - for modify read: it will delete and then create a new shortcut according to the modified information.

You can test what will happen by checking the Test box, only the first 20 shortcut manglings will be displayed.  If you enter nothing in the regex fields and hit the Go button then it will delete and then create the existing shortcuts with no changes - think of it as 'refreshing' your stale shortcuts.

****NOTE**** All the pictures changed with v0.2+ - that's why they're not here anymore.

For a roundup of the regex you can use, see here, for more than you ever wanted know, see here.

You can also click on the RegEx to have it open the first page in your browser, (images were grabbed before I added the RegEx link - I'm not going crazy, it only looks like it).

DISCLAIMER: Because I code for my enjoyment and not others: No error checking, trapping, safety nets, etc.  smiley

By design the program should only ever effect shortcuts, (*.lnk), but if you get it to launch a pre-emptive nuclear strike against Melbourne, Australia, just remember......I won't be around to fix the bug.

It's all in the archive up here.

Are you saying that you have 32,220 rules/entries in File Punter?  If so, why?

I think he means running over two lots of 16110 files, (number of image files quoted in another post).
« Last Edit: July 09, 2012, 05:22:05 AM by 4wd » Logged

Four wheel drive: Helping you get stuck faster, harder, further from help...........and it's no different on this forum Evil
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #13 on: June 24, 2012, 03:32:55 PM »


Are you saying that you have 32,220 rules/entries in File Punter?  If so, why?

Well, at least we know that File Punter works successfully with such a large task.  Plus I still don't understand how to do those RegEx expressions.  As a side note on File Punter, by the way, seems I can leave it running and doing its thing in the background with no problem, while I search the web and work on other stuff.  File Punter doesn't hog the computer resources, and doesn't trip over itself just because I bring up some website in Chrome.  That's an enormous plus.

The RegEx you and jgpaiva provided (using ReNamer), though, did work great "getting rid of that extra junk" in file names.  That saved me a lot of work and frustration.


Logged
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #14 on: June 24, 2012, 03:45:19 PM »


4wd, boy am I glad you were bored.  Appears you've created the world's ONLY Windows GUI program to alter shortcuts.  Definitely beats that other 'command line' version I found.  I haven't tested BSM (Batch Shortcut Modifier) yet, but it looks fantastic.  Thanks a million.

Logged
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #15 on: June 25, 2012, 11:09:42 AM »


Good to go on this thread as well.  Two great solutions for modifying shortcuts.

DONE!

Logged
lujomu
Member
**
Posts: 36

View Profile Give some DonationCredits to this forum member
« Reply #16 on: June 25, 2012, 04:46:21 PM »

Albeit hard to find, there already is a GUI tool that can alter shortcuts: Shortcuts Search And Replace

It has served me well on numerous occasions!
Logged
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #17 on: June 25, 2012, 04:53:43 PM »


Goodness!  Then three to choose from.  Hope this thread comes up in Google searches for those desiring this functionality.

Logged
4wd
Supporting Member
**
Posts: 3,262



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #18 on: June 25, 2012, 09:27:14 PM »

Albeit hard to find, there already is a GUI tool that can alter shortcuts: Shortcuts Search And Replace

I don't think that can change the actual target, just the target path, (and other bits).
Logged

Four wheel drive: Helping you get stuck faster, harder, further from help...........and it's no different on this forum Evil
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #19 on: July 08, 2012, 03:00:47 AM »


4wd, as usual, I'm a bit confused....

From the Properties window for a particular shortcut, below is the present target:

C:\4\QQQ\images\50501\_50501_20101_20102_.png

I want to change the above target to:

C:\5\QQQ\images\50501\_50501_20101_20102_.png

The name of the shortcut is:

20101 20102[.lnk]

The present location of the shortcut is:

C:\5\QQQ\shortcuts 1_x_178\50501\20101\

What would the RegEx entries in BSM be to accomplish this?

(There will be thousands of such changes....)

Thanks much.

Logged
4wd
Supporting Member
**
Posts: 3,262



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #20 on: July 08, 2012, 05:36:41 AM »

It won't work due to a slight oversight on my part  embarassed

I stupidly changed the name of the shortcut instead of the target within the shortcut.

I'll fix it and get back to you.

OK, fixed, (I think)...well, it worked here with your example above.

UPDATE:
  • Fix: Changes the target name and not the shortcut
  • Fix: Modifies the working directory, (which I forgot).
  • Added: A version number.
  • Added: Old and New label in case the tooltips weren't enough.

It's up there.

For your case above:


And this is what you'll get:


Search for:    C:\\4(.+)
Replace with: C:\\5\1

C:\\4(.+) - Match C:\4 and put the remaining characters into a group, (one (1) in this case since it's the first group)
C:\\5\1 - Replace with C:\5 and the characters from group one, (\1).

Because \ is a special character in RegEx you need to escape it by putting \ in front, hence the \\.
« Last Edit: July 08, 2012, 06:26:34 AM by 4wd » Logged

Four wheel drive: Helping you get stuck faster, harder, further from help...........and it's no different on this forum Evil
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #21 on: July 08, 2012, 11:38:50 PM »


Fwd, something's still amiss.  Probably the RegEx...

To clarify the objective, let's pretend I'm having a conversation with your Batch Shortcut Modifier.  I say to BSM:

"Here is a big shortcuts folder full of sub-folders, and sub-sub-folders (all neatly sliced-and-diced in a tree structure, appropriately grouped and re-grouped by purpose).  Burried herein are, again, 'shortcuts' that all point to images in a huge main image folder, divided into sub-folders which hold the images.  Please recursively search through everything in the big shortcuts folder.  If you come upon a shortcut containing any target reference to 'C:\4\...,' please change it to 'C:\5\...'"

I pasted in the BSM commands as you suggested, and ran two tests:

Test #1

Folder:
C:\5\QQQ\shortcuts 1_x_178\50501\20101  (a sub-sub-folder actually containing shortcuts)

Path of target:  C:\\4(.+)  changed to  C:\\5\1

Test box checked.  Recurse box un-checked.

Results....

New shortcut:

C:\5\QQQ\shortcuts 1_x_178\50501\20101\20101 20102  (correct, same as old, unchanged)

New target:

C:\5\QQQ\images\50501\20101 20102  (does NOT appear to be correct)

Test #2

Folder:
C:\5\QQQ\shortcuts 1_x_178\  (a base folder, holding sub-folders, and sub-sub-folders)

Path of target:  C:\\4(.+)  changed to  C:\\5\1

Test box checked.  Recurse box checked.

Results....

Identical to previous test, Test #1.

=====

Following the BSM testing mode, I ran BSM in actual mode.  BSM seemed very fast and efficient.

Afterward, examining (Windows) Properties window for shortcut "20101 20102[.lnk]":

Target = "C:\5\QQQ\images\50501\20101 20102"

which is not correct; should be:

Target = "C:\5\QQQ\images\50501\_50501_20101_20102_.png"

Remember, early part of path in shortcut was originally:

Target = "C:\4\QQQ\images\50501\_50501_20101_20102_.png"

so BSM did indeed successfully change the beginning of the path, as requested.

However, the end part, targeting the .png file, is not correct.

My naive hunch is the RegEx needs to be adjusted in some way.


Logged
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #22 on: July 08, 2012, 11:46:40 PM »


BSM enhancement request 1:

Upon successful completion of the job, small window pops up with something similar to the following, with C being the most preferred:

A)  DONE!

B)  DONE!  xxxx shortcuts processed.

C)  DONE!  xxxx shortcuts changed; yyyy shortcuts left alone.


BSM enhancement request 2:

Set up an .ini file containing the last used parameters, and re-use next time program is run.


Logged
4wd
Supporting Member
**
Posts: 3,262



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #23 on: July 09, 2012, 01:31:34 AM »

Test #1

Folder:
C:\5\QQQ\shortcuts 1_x_178\50501\20101  (a sub-sub-folder actually containing shortcuts)

Path of target:  C:\\4(.+)  changed to  C:\\5\1

Test box checked.  Recurse box un-checked.

Results....

New shortcut:

C:\5\QQQ\shortcuts 1_x_178\50501\20101\20101 20102  (correct, same as old, unchanged)

New target:

C:\5\QQQ\images\50501\20101 20102  (does NOT appear to be correct)

OK, I'm confused here - prior to v0.2 it reported New shortcut/New target in Test mode.

With v0.2, it reports Old Target/New Target, (as you can see in my post above), because the actual shortcut doesn't get renamed, (as it was doing in the prior version - I naively thought the shortcut would have the same name as the target).

Are you sure you're using v0.2 ?

Here's a directory setup as you've described above showing that the properties for the shortcut point to the old C:\4\QQQ.... path, (this is using the parameters from your Test #2 but Test #1 also worked):



Here's the Test output with arrows associating between things:



This is the result of execution, the shortcut properties now point to the image in the other directory:




BSM enhancement request 1:
C)  DONE!  xxxx shortcuts changed; yyyy shortcuts left alone.

See what I can do.

Quote
Set up an .ini file containing the last used parameters, and re-use next time program is run.

Easy enough, I'll have it save on close.

UPDATE BSM v0.3 (here):
  • Added: Saves path/regex in an ini file on exit.
  • Added: Generates a report when it's finished.

Regarding the report: If nothing went wrong then all it will say is the total number of shortcuts and there was no problem.  If something went wrong it will open a log file, (%TEMP%\BSM.log), in your default text editor.

NOTE: BSM works by replacing the existing shortcut by first deleting it, then creating a new one with the new data.  The log will show any shortcuts that failed to be deleted or failed to be created, (mark a couple of your shortcuts as Read-Only if you want to see what happens).
« Last Edit: July 09, 2012, 05:27:49 AM by 4wd » Logged

Four wheel drive: Helping you get stuck faster, harder, further from help...........and it's no different on this forum Evil
nkormanik
Participant
*
Posts: 283

View Profile Give some DonationCredits to this forum member
« Reply #24 on: July 09, 2012, 01:57:10 PM »


My apologies, 4wd.  I was testing with the previous version.

Current version works perfectly.

BSM is the best Batch Shortcut Modifier on the planet.

By the way, for those following, above in this thread was mentioned the program "Shortcuts Search And Replace."  That, too, is a fine program.  HOWEVER, for large jobs in my tests 4wd's BSM is about 100X faster.

Thanks very, very much, 4wd!


Logged
Pages: [1] 2 Next   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.053s | Server load: 0.08 ]