topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Monday October 26, 2020, 2:05 am
  • Proudly celebrating 15+ 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

Last post Author Topic: DONE: Batch adjust shortcut targets  (Read 65291 times)

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
DONE: Batch adjust shortcut targets
« on: June 22, 2012, 05:26 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
[email protected]


skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,208
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #1 on: June 22, 2012, 05:36 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?

kunkel321

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 521
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #2 on: June 22, 2012, 05:43 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).

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #3 on: June 22, 2012, 06:02 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.


nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #4 on: June 22, 2012, 06:25 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.


skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,208
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #5 on: June 22, 2012, 06:38 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?

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #6 on: June 22, 2012, 06:50 PM »

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


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,386
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #7 on: June 23, 2012, 12:16 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)

2012-06-23_17-41-48.jpg

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 :)

Also BSM in the other archive

2014-10-27 22_39_51.png

BSC source:
Code: AutoIt [Select]
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=cow.ico
  3. #AutoIt3Wrapper_Outfile=BSC.exe
  4. #AutoIt3Wrapper_UseUpx=n
  5. #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
  6. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  7. #Include <GUIConstantsEx.au3>
  8. #include <EditConstants.au3>
  9. #include <ProgressConstants.au3>
  10. #Include <WindowsConstants.au3>
  11. #include <StaticConstants.au3>
  12. #include 'RecFileListToArray.au3'
  13.  
  14. #Region ### START Koda GUI section ### Form=
  15. $Form1 = GUICreate("BSC v0.1", 349, 180, 192, 124)
  16. $Go = GUICtrlCreateButton("Go", 255, 137, 75, 25)
  17. GUICtrlSetTip(-1, 'Starts shortcut creation')
  18. $Button1 = GUICtrlCreateButton("Source", 280, 13, 50, 25)
  19. GUICtrlSetTip(-1, 'Select a source folder to create' & @CRLF & 'shortcuts for files')
  20. $Button2 = GUICtrlCreateButton("Dest", 280, 56, 50, 25)
  21. GUICtrlSetTip(-1, 'Select a destination folder to put' & @CRLF & 'the shortcuts in')
  22. $progress = GUICtrlCreateProgress(15, 96, 314, 17)
  23. $Input1 = GUICtrlCreateInput("", 16, 14, 258, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
  24. $Input2 = GUICtrlCreateInput("", 17, 57, 256, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY))
  25. $cRecurse = GUICtrlCreateCheckbox("Recurse", 152, 127, 66, 17)
  26. GUICtrlSetTip(-1, 'Recurse down through folder structure')
  27. $Input3 = GUICtrlCreateInput("*.*", 16, 139, 121, 21)
  28. GUICtrlSetTip(-1, 'Wildcard filter for files to' & @CRLF & 'create shortcuts for')
  29. $oDir = GUICtrlCreateCheckbox("One folder", 152, 151, 79, 17)
  30. GUICtrlSetTip(-1, 'Outputs shortcuts to destination folder,' & @CRLF & 'does not duplicate folder tree')
  31. GUICtrlSetState(-1, $GUI_DISABLE)
  32. #EndRegion ### END Koda GUI section ###
  33.  
  34.  
  35.         $nMsg = GUIGetMsg()
  36.         Switch $nMsg
  37.                 Case $cRecurse
  38.                         If (GUICtrlRead($cRecurse) = 1) Then
  39.                                 GUICtrlSetState($oDir, $GUI_ENABLE)
  40.                         Else
  41.                                 GUICtrlSetState($oDir, $GUI_UNCHECKED)
  42.                                 GUICtrlSetState($oDir, $GUI_DISABLE)
  43.                         EndIf
  44.                 Case $Button1
  45.                         $sPath = FileSelectFolder('Source folder:', '', 4)
  46.                         If @error = 1 Then $sPath = ''
  47.                         GUICtrlSetData($Input1, $sPath)
  48.                 Case $Button2
  49.                         $dPath = FileSelectFolder('Destination folder:', '', 4)
  50.                         If @error = 1 Then $dPath = ''
  51.                         GUICtrlSetData($Input2, $dPath)
  52.                 Case $Go
  53.                         If $sPath <> '' And $dPath <> '' Then
  54.                                 $filter = GUICtrlRead($Input3)
  55.                                 If (GUICtrlRead($cRecurse) = 1) Then
  56.                                         If Not (GUICtrlRead($oDir) = 1) Then
  57.                                                 $output = _RecFileListToArray($sPath, '*', 2, 1, 0, 1, '*.lnk')
  58.                                                 _DupeTree($sPath, $dPath)
  59.                                         EndIf
  60.                                         $output = _RecFileListToArray($sPath, $filter, 1, 1, 0, 1, '*.lnk')
  61.                                 Else
  62.                                         $output = _RecFileListToArray($sPath, $filter, 1, 0, 0, 1, '*.lnk')
  63.                                 EndIf
  64.                                 _BSC($sPath, $dPath, (GUICtrlRead($oDir) = 1))
  65.                         EndIf
  66.                 Case $GUI_EVENT_CLOSE
  67.                         Exit
  68.         EndSwitch
  69.  
  70.  
  71. Func _BSC($src, $dest, $oneDir = 0)
  72.         $prg = 0
  73.         $diff = 100 / $output[0]
  74.         GUICtrlSetData($progress, $prg)
  75.         For $i = 1 To $output[0]
  76.                 If $oneDir = 0 Then
  77.                         $temp = $dest & '\' & $output[$i]
  78.                 Else
  79.                         $temp = $dest & StringMid($output[$i], StringInStr($output[$i], '\', 0, -1))
  80.                 EndIf
  81.                 FileCreateShortcut($src & '/' & $output[$i], $temp)
  82.                 $prg += $diff
  83.                 GUICtrlSetData($progress, $prg)
  84.         Next
  85.  
  86.  
  87. Func _DupeTree($src, $dest)
  88.         Local $i
  89.         For $i = 1 To $output[0]
  90.                 If Not FileExists($dest & '\' & $output[$i]) Then DirCreate($dest & '\' & $output[$i])
  91.         Next

BSM source:
Code: AutoIt [Select]
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Outfile=BSM.exe
  3. #AutoIt3Wrapper_UseUpx=n
  4. #AutoIt3Wrapper_Res_Fileversion=0.7.0.4
  5. #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
  6. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  7.  
  8. #include <GUIConstantsEx.au3>
  9. #include <EditConstants.au3>
  10. #include <ProgressConstants.au3>
  11. #include <WindowsConstants.au3>
  12. #include <StaticConstants.au3>
  13. #include <GuiStatusBar.au3>
  14. #include <GuiListView.au3>
  15. #include <ListViewConstants.au3>
  16. #include <Array.au3>
  17. #include <Date.au3>
  18. #include <File.au3>
  19.  
  20. Global $iSRC = 'C:\', $iPRS = '(.*)', $iPRR = '\1', $iNRS = '(.*)', $iNRR = '\1', $iREC = False, $iTST = False
  21.  
  22. _GetIni()
  23.  
  24. #Region ### START Koda GUI section ### Form=
  25. $guiBSM = GUICreate("BSM v0.7", 354, 251)
  26. $Go = GUICtrlCreateButton("Go", 256, 193, 75, 25)
  27. GUICtrlSetTip(-1, "Starts shortcut modification")
  28. $Button1 = GUICtrlCreateButton("Folder", 280, 13, 50, 25)
  29. GUICtrlSetTip(-1, "Folder with shortcuts")
  30. $progress = GUICtrlCreateProgress(16, 152, 314, 17)
  31. $Input1 = GUICtrlCreateInput($iSRC, 16, 14, 258, 21, $GUI_SS_DEFAULT_INPUT)
  32.  
  33. $cRecurse = GUICtrlCreateCheckbox("Recurse", 170, 194, 66, 17)
  34. If $iREC Then GUICtrlSetState($cRecurse, $GUI_CHECKED)
  35. GUICtrlSetTip(-1, "Recurse down through folder structure")
  36. $cTest = GUICtrlCreateCheckbox("Test", 90, 190, 56, 25)
  37. If $iTST Then GUICtrlSetState($cTest, $GUI_CHECKED)
  38. GUICtrlSetTip(-1, "Display test output")
  39.  
  40. $labelRx = GUICtrlCreateLabel("RegEx", 19, 196, 36, 17)
  41. GUICtrlSetTip(-1, "Click to open browser at RegEx page")
  42. GUICtrlSetColor(-1, '0x000099')
  43.  
  44. $Input2 = GUICtrlCreateInput($iPRS, 16, 80, 140, 21)
  45. GUICtrlSetTip(-1, "Path RegEx to search for")
  46. $Input4 = GUICtrlCreateInput($iPRR, 16, 110, 140, 21)
  47. GUICtrlSetTip(-1, "Path RegEx replacement text")
  48. $Input5 = GUICtrlCreateInput($iNRS, 190, 80, 140, 21)
  49. GUICtrlSetTip(-1, "Name RegEx to search for")
  50. $Input6 = GUICtrlCreateInput($iNRR, 190, 110, 140, 21)
  51. GUICtrlSetTip(-1, "Name RegEx replacement text")
  52. GUICtrlCreateLabel("Path of target", 52, 48, 70, 17)
  53. GUICtrlCreateLabel("Name of target", 215, 49, 75, 17)
  54. GUICtrlCreateLabel("Old", 160, 85, 25, 21, $SS_CENTER)
  55. GUICtrlCreateLabel("New", 160, 115, 25, 21, $SS_CENTER)
  56. $StatusBar1 = _GUICtrlStatusBar_Create($guiBSM)
  57. WinMove("BSM v0.7", '', IniRead($inifile, 'Main', 'XPos', 20), IniRead($inifile, 'Main', 'YPos', 20))
  58. #EndRegion ### END Koda GUI section ###
  59.  
  60.         $nMsg = GUIGetMsg()
  61.         Switch $nMsg
  62.                 Case $labelRx
  63.                         ShellExecute('http://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm')
  64.                 Case $Button1
  65.                         $iSRC = FileSelectFolder('Select folder:', '', 4)
  66.                         If @error = 1 Then $iSRC = ''
  67.                         GUICtrlSetData($Input1, $iSRC)
  68.                 Case $Go
  69.                         $iSRC = GUICtrlRead($Input1)
  70.                         If Not FileExists($iSRC) Then
  71.                                 MsgBox(48, 'BSM Error', 'Not a valid path')
  72.                         Else
  73.                                 $output = ''
  74.                                 GUICtrlSetData($progress, 0)
  75.                                 $iPRS = GUICtrlRead($Input2)
  76.                                 $iPRR = GUICtrlRead($Input4)
  77.                                 $iNRS = GUICtrlRead($Input5)
  78.                                 $iNRR = GUICtrlRead($Input6)
  79.  
  80.                                 If $iPRS = '' Then $iPRS = '(.*)'
  81.                                 If $iPRR = '' Then $iPRR = '\1'
  82.                                 If $iNRS = '' Then $iNRS = '(.*)'
  83.                                 If $iNRR = '' Then $iNRR = '\1'
  84.  
  85.                                 If $iSRC <> '' Then
  86.                                         _GUICtrlStatusBar_SetText($StatusBar1, 'Finding shortcuts')
  87.                                         Global $start = TimerInit()
  88.                                         If (GUICtrlRead($cRecurse) = 1) Then
  89.                                                 $output = _FileListToArrayPlus($iSRC, "*.lnk", 1, 0, "", 2, True)
  90.                                         Else
  91.                                                 $output = _FileListToArrayPlus($iSRC, "*.lnk", 1, 0, "", 2, False)
  92.                                         EndIf
  93.                                         If @error = 0 Or IsArray($output) Then
  94.                                                 _BSM($output, (GUICtrlRead($cTest) = 1))
  95.                                         Else
  96.                                                 MsgBox(48, 'BSM Error', 'No shortcuts found')
  97.                                         EndIf
  98.                                 EndIf
  99.                         EndIf
  100.                 Case $GUI_EVENT_CLOSE
  101.                         $wPos = WinGetPos("BSM v0.7")
  102.                         IniWrite($inifile, 'Main', 'Folder', $iSRC)
  103.                         IniWrite($inifile, 'Main', 'PathSearch', $iPRS)
  104.                         IniWrite($inifile, 'Main', 'PathReplace', $iPRR)
  105.                         IniWrite($inifile, 'Main', 'NameSearch', $iNRS)
  106.                         IniWrite($inifile, 'Main', 'NameReplace', $iNRR)
  107.                         IniWrite($inifile, 'Main', 'Recurse', (GUICtrlRead($cRecurse) = 1))
  108.                         IniWrite($inifile, 'Main', 'Test', (GUICtrlRead($cTest) = 1))
  109.                         IniWrite($inifile, 'Main', 'XPos', $wPos[0])
  110.                         IniWrite($inifile, 'Main', 'YPos', $wPos[1])
  111.                         Exit
  112.         EndSwitch
  113.  
  114.  
  115. Func _BSM($files, $test = False)
  116.         Local $j = 1, $target, $targetPath, $newTarget, $newWorking, $prg = 1, $fDScut = 0, $fDLog = '', $fCScut = 0, $fCLog = '', $max, $nMsg2
  117.         Local $Percent, $Percent_prev, $interrupt = False
  118.         Dim $temp[101][2]
  119.  
  120.         $max = $files[0]
  121.         Switch $test
  122.                 Case True
  123.                         _GUICtrlStatusBar_SetText($StatusBar1, 'Creating test output')
  124.                         If $files[0] > 100 Then $max = 100
  125.                 Case Else
  126.                         _GUICtrlStatusBar_SetText($StatusBar1, 'Processing ' & $max & ' shortcuts')
  127.         EndSwitch
  128.  
  129.         GUICtrlSetData($Go, 'Stop')
  130.  
  131.         For $i = 1 To $max
  132.                 $nMsg2 = GUIGetMsg()
  133.                 Switch $nMsg2
  134.                         Case $Go
  135.                                 $interrupt = True
  136.                                 ExitLoop
  137.                         Case Else
  138.                                 $details = FileGetShortcut($files[$i])
  139.                                 If $details[0] = "" Then
  140.                                         _ArrayDelete($files, $i)
  141.                                         $max -= 1
  142.                                         $i -= 1
  143.                                 Else
  144.                                         $targetPath = StringLeft($details[0], StringInStr($details[0], '\', 0, -1) - 1)
  145.                                         $target = StringMid($details[0], StringInStr($details[0], '\', 0, -1) + 1)
  146.  
  147.                                         $newTarget = StringRegExpReplace($targetPath, $iPRS, $iPRR) & '\' & StringRegExpReplace($target, $iNRS, $iNRR)
  148.                                         $newWorking = StringRegExpReplace($details[1], $iPRS, $iPRR)
  149.                                         Select
  150.                                                 Case $test
  151.                                                         $temp[$i][0] = $details[0]
  152.                                                         $temp[$i][1] = $newTarget
  153.                                                         $temp[0][0] = $i
  154.                                                 Case Else
  155.                                                         If FileDelete($files[$i]) Then
  156.                                                                 If Not FileCreateShortcut($newTarget, $files[$i], $newWorking, $details[2], $details[3], $details[4], '', $details[5], $details[6]) Then
  157.                                                                         $fCScut += 1
  158.                                                                         $fCLog &= $files[$i] & @CRLF
  159.                                                                 EndIf
  160.                                                         Else
  161.                                                                 $fDScut += 1
  162.                                                                 $fDLog &= $files[$i] & @CRLF
  163.                                                         EndIf
  164.                                         EndSelect
  165.                                         $Percent = Round(($i / $max) * 100, 0)
  166.                                         If $Percent <> $Percent_prev Then
  167.                                                 GUICtrlSetData($progress, $Percent)
  168.                                                 $Percent_prev = $Percent
  169.                                         EndIf
  170.                                 EndIf
  171.                 EndSwitch
  172.         Next
  173.  
  174.         GUICtrlSetData($Go, 'Go')
  175.         If $interrupt Then
  176.                 _GUICtrlStatusBar_SetText($StatusBar1, 'Interrupted')
  177.         Else
  178.                 _GUICtrlStatusBar_SetText($StatusBar1, 'Finished: ' & Round(TimerDiff($start) / 1000, 1) & ' seconds')
  179.         EndIf
  180.  
  181.         If $test Then
  182.                 _ArrayBox($temp, 1, 'BSM Test Output', '|Old Shortcut Target|New Shortcut Target', True)
  183.         Else
  184.                 If $fDScut > 0 Or $fCScut > 0 Or $interrupt Then
  185.                         _Log($fCLog, $fCScut, $fDLog, $fDScut, $files[0], $interrupt)
  186.                 Else
  187.                         MsgBox(64, 'BSM Results', 'Total shortcuts: ' & $files[0] & @CRLF & 'No failures during Delete/Create')
  188.                 EndIf
  189.         EndIf
  190.  
  191.         GUICtrlSetData($progress, 0)
  192. EndFunc   ;==>_BSM
  193.  
  194.  
  195. Func _Log($cl, $cc, $dl, $dc, $tot, $int)
  196.         Local $fLog = FileOpen(@TempDir & '\BSM.log', 138)
  197.         If $fLog = -1 Then
  198.                 MsgBox(64, 'BSM Error', 'Unable to open log file:' & @CRLF & @TempDir & '\BSM.log' & @CRLF & 'for output')
  199.         Else
  200.                 FileWrite($fLog, 'BSM results ' & _Now() & @CRLF & 'Total shortcuts: ' & $tot & @CRLF & @CRLF)
  201.                 If $int Then FileWrite($fLog, '**** INTERRUPTED ****' & @CRLF & @CRLF)
  202.                 FileWrite($fLog, 'Shortcuts that failed to be deleted: ' & $dc & @CRLF)
  203.                 If $dc > 0 Then FileWrite($fLog, $dl & @CRLF & @CRLF)
  204.                 FileWrite($fLog, 'Shortcuts that failed to be created: ' & $cc & @CRLF)
  205.                 If $cc > 0 Then FileWrite($fLog, $cl & @CRLF & @CRLF)
  206.                 FileClose($fLog)
  207.                 ShellExecuteWait(@TempDir & '\BSM.log')
  208.         EndIf
  209. EndFunc   ;==>_Log
  210.  
  211.  
  212. Func _GetIni()
  213.         If FileExists($inifile) Then
  214.                 $iSRC = IniRead($inifile, 'Main', 'Folder', 'C:\')
  215.                 $iPRS = IniRead($inifile, 'Main', 'PathSearch', '(.*)')
  216.                 $iPRR = IniRead($inifile, 'Main', 'PathReplace', '\1')
  217.                 $iNRS = IniRead($inifile, 'Main', 'NameSearch', '(.*)')
  218.                 $iNRR = IniRead($inifile, 'Main', 'NameReplace', '\1')
  219.                 $iREC = IniRead($inifile, 'Main', 'Recurse', 'False')
  220.                 $iTST = IniRead($inifile, 'Main', 'Test', 'False')
  221.         EndIf
  222. EndFunc   ;==>_GetIni
  223.  
  224.  
  225. ;===============================================================================
  226. ;
  227. ; Function Name:    _ArrayBox()
  228. ; Description:      Shows an array in a GUI window.  Improved version of _ArrayDisplay
  229. ; Parameter(s):     $Array - An array, 1d or 2d, 0-based or 1-based
  230. ; $ArrayBase - 1 or 0 - tells what base the array is
  231. ; $sTitle - the title to put on the output window
  232. ; $Width, $Height, $Left, $Top - Set the size and position of the output window
  233. ; Requirement(s):   $Array must be 1d or 2d.  If 1-based, then arraysize is assumed to be $Array[0] or $Array[0][0]
  234. ; Return Value(s):  -1 = $Array is not an array, error=1
  235. ; Author(s):        Mike Ratzlaff <[email protected]>
  236. ; Revision: 20050620A
  237. ;
  238. ;===============================================================================
  239. ;
  240. Func _ArrayBox(ByRef $Array, $ArrayBase = 1, $sTitle = 'Array Box', $sTemp = '', $sIni = False, $Width = 400, $Height = 200, $Left = -1, $Top = -1)
  241.         Dim $AllDone = 0, $msg, $i, $j, $ArrayDimensions = UBound($Array, 0)
  242.         Dim $hndForm_Main, $hndListView_Display
  243.  
  244.         If $ArrayDimensions = 0 Then
  245.                 SetError(1)
  246.                 Return -1
  247.         EndIf
  248.  
  249.         ;Setup
  250.         If $ArrayBase <> 0 Then $ArrayBase = 1
  251.         If $ArrayBase Then
  252.                 Select
  253.                         Case $ArrayDimensions = 1
  254.                                 $ArrayMax = $Array[0]
  255.                         Case $ArrayDimensions = 2
  256.                                 $ArrayMax = $Array[0][0]
  257.                 EndSelect
  258.         Else
  259.                 $ArrayMax = UBound($Array, 1) - 1
  260.         EndIf
  261.  
  262.         ;Create GUI
  263.         If $Height < 100 Then $Height = 100
  264.         If $Width < 100 Then $Width = 100
  265.         $hndForm_Main = GUICreate($sTitle, $Width, $Height, $Left, $Top, BitOR($WS_POPUP, $WS_CAPTION, $WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_EX_DLGMODALFRAME))
  266.  
  267.         ;Create List Box
  268.         If $ArrayDimensions = 1 Then
  269.                 If $sTemp = '' Then $sTemp = 'Index|Value'
  270.         ElseIf $ArrayDimensions = 2 Then
  271.                 If $sTemp = '' Then
  272.                         $sTemp = 'Index'
  273.                         For $i = 0 To UBound($Array, 2) - 1
  274.                                 $sTemp = $sTemp & '|' & $i
  275.                         Next
  276.                 EndIf
  277.         EndIf
  278.         $hndListView_Display = GUICtrlCreateListView($sTemp, 0, 0, $Width, $Height - 24, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOSORTHEADER))
  279.         GUICtrlSetResizing($hndListView_Display, BitOR($GUI_DockLeft, $GUI_DockTop, $GUI_DockRight, $GUI_DockBottom))
  280.         _GUICtrlListView_SetColumnWidth($hndListView_Display, 0, 36)
  281.  
  282.         ;Create Controls, Show GUI
  283.         $hndButton_Close = GUICtrlCreateButton('&Close', $Width - 80, $Height - 24, 80, 24)
  284.         GUICtrlSetResizing($hndButton_Close, BitOR($GUI_DockRight, $GUI_DockBottom, $GUI_DockSize))
  285.         GUICtrlSetState($hndButton_Close, $GUI_DefButton)
  286.         If $sIni Then WinMove($sTitle, '', IniRead($inifile, 'Test', 'XPos', 20), IniRead($inifile, 'Test', 'YPos', 20), IniRead($inifile, 'Test', 'Width', 400), IniRead($inifile, 'Test', 'Height', 200))
  287.         GUISetState(@SW_SHOW, $hndForm_Main)
  288.  
  289.         ;Display Array
  290.         Select
  291.                 Case $ArrayDimensions = 1 ;1-Dimensional Array
  292.                         For $i = $ArrayBase To $ArrayMax
  293.                                 GUICtrlCreateListViewItem($i & '|' & $Array[$i], $hndListView_Display)
  294.                         Next ;$i
  295.                 Case $ArrayDimensions = 2 ;2-Dimensional Array
  296.                         For $i = $ArrayBase To $ArrayMax
  297.                                 $sTemp = $Array[$i][0]
  298.                                 For $j = 1 To UBound($Array, 2) - 1
  299.                                         $sTemp = $sTemp & '|' & $Array[$i][$j]
  300.                                 Next ;$j
  301.                                 GUICtrlCreateListViewItem('[' & $i & ']|' & $sTemp, $hndListView_Display)
  302.                         Next ;$i
  303.                 Case Else ;Unhandled Type
  304.  
  305.         EndSelect
  306.         _GUICtrlListView_SetColumnWidth($hndListView_Display, 1, $LVSCW_AUTOSIZE)
  307.         _GUICtrlListView_SetColumnWidth($hndListView_Display, 2, $LVSCW_AUTOSIZE)
  308.  
  309.         ;Wait for user to close box
  310.         Do
  311.                 $msg = GUIGetMsg()
  312.                 Select
  313.                         Case $msg = $GUI_EVENT_CLOSE
  314.                                 $AllDone = 1
  315.                         Case $msg = $hndButton_Close
  316.                                 $AllDone = 1
  317.                 EndSelect
  318.         Until $AllDone
  319.         Local $wPos = WinGetPos($sTitle)
  320.         If @error = 0 And $sIni Then
  321.                 IniWrite($inifile, 'Test', 'XPos', $wPos[0])
  322.                 IniWrite($inifile, 'Test', 'YPos', $wPos[1])
  323.                 IniWrite($inifile, 'Test', 'Width', $wPos[2])
  324.                 IniWrite($inifile, 'Test', 'Height', $wPos[3])
  325.         EndIf
  326.         GUIDelete($hndForm_Main)
  327.         Return 0
  328. EndFunc   ;==>_ArrayBox
  329.  
  330.  
  331. ; #FUNCTION# =====================================================================================================================
  332. ; _FileListToArrayPlus($sPath, $sInclude = "*", $iFlag = 0, $sExcludeFolder = "", $sExclude = "", $iPathType = 0, $bRecursive = False)
  333. ; Name...........:  _FileListToArray_Rec
  334. ; Parameters ....:  $sPath: Folder to search
  335. ;     $sInclude: String to match on (wildcards allowed, multiples delimited by ;)
  336. ;     $iFlag: Returned data type. 0 = Files and folders (default), 1 = Files only, 2 = Folders only
  337. ;     $sExcludeFolder: List of folders to exclude from search (wildcards allowed, multiples delimited by ;)
  338. ;     $sExclude: List of filenames to exclude from search (wildcards allowed, multiples delimited by ;)
  339. ;     $iPathType: Returned data format. 0 = Filename only (default), 1 = Path relative to $sPath, 2 = Full path/filename
  340. ;     $bRecursive: False = Search $sPath folder only (default), True = Search $sPath and all subfolders
  341. ; Author ........:  Half the Autoit Community (Forum thread #96952)
  342. ;===================================================================================================================================
  343.  
  344. Func _FileListToArrayPlus($sPath, $sInclude = "", $iFlag = 0, $sExcludeFolder = "", $sExclude = "", $iPathType = 0, $bRecursive = False)
  345.         Local $sRet = "", $sReturnFormat = "", $interrupt = False
  346.         $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing slash
  347.         If Not FileExists($sPath) Then Return SetError(1, 1, "")
  348.         ; Edit include files list
  349.         If $sInclude = "*" Then $sInclude = ""
  350.         If $sInclude Then
  351.                 If StringRegExp($sInclude, "[\\/ :><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "") ; invalid characters test
  352.                 $sInclude = StringRegExpReplace(StringRegExpReplace($sInclude, "(\s*;\s*)+", ";"), "\A;|;\z", "") ; Strip unwanted whitespace
  353.                 $sInclude = StringRegExpReplace($sInclude, "[][$.+^{}()]", "\\$0"); Ignore special characters
  354.                 $sInclude = StringReplace(StringReplace(StringReplace($sInclude, "?", "."), "*", ".*?"), ";", "$|") ; Convert ? to ., * to .*?, and ; to |
  355.                 $sInclude = "(?i)\A(" & $sInclude & "$)"; case-insensitive, match from first char, terminate strings
  356.         EndIf
  357.         ; Edit exclude folders list
  358.         If $sExcludeFolder Then
  359.                 $sExcludeFolder = StringRegExpReplace(StringRegExpReplace($sExcludeFolder, "(\s*;\s*)+", ";"), "\A;|;\z", "") ; Strip unwanted whitespace
  360.                 $sExcludeFolder = StringRegExpReplace($sExcludeFolder, "[][$.+^{}()]", "\\$0"); Ignore special characters
  361.                 $sExcludeFolder = StringReplace(StringReplace(StringReplace($sExcludeFolder, "?", "."), "*", ".*?"), ";", "$|") ; Convert ?=.  *=.*?  ;=|
  362.                 $sExcludeFolder = "(?i)\A(?!" & $sExcludeFolder & "$)"; case-insensitive, match from first char, terminate strings
  363.         EndIf
  364.         ; Edit exclude files list
  365.         If $sExclude Then
  366.                 $sExclude = StringRegExpReplace(StringRegExpReplace($sExclude, "(\s*;\s*)+", ";"), "\A;|;\z", "") ; Strip unwanted whitespace
  367.                 $sExclude = StringRegExpReplace($sExclude, "[][$.+^{}()]", "\\$0"); Ignore special characters
  368.                 $sExclude = StringReplace(StringReplace(StringReplace($sExclude, "?", "."), "*", ".*?"), ";", "$|") ; Convert ?=.  *=.*?  ;=|
  369.                 $sExclude = "(?i)\A(?!" & $sExclude & "$)"; case-insensitive, match from first char, terminate strings
  370.         EndIf
  371.         ;   MsgBox(1,"Masks","File include: " & $sInclude & @CRLF & "File exclude: " & $sExclude & @CRLF & "Dir exclude : " & $sExcludeFolder)
  372.  
  373.         If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
  374.  
  375.         Local $sOrigPathLen = StringLen($sPath), $aQueue[64] = [1, $sPath], $iQMax = 63
  376.         While $aQueue[0]
  377.                 $WorkFolder = $aQueue[$aQueue[0]]
  378.                 $aQueue[0] -= 1
  379.                 $search = FileFindFirstFile($WorkFolder & "*")
  380.                 If @error Then ContinueLoop
  381.                 Switch $iPathType
  382.                         Case 1 ; relative path
  383.                                 $sReturnFormat = StringTrimLeft($WorkFolder, $sOrigPathLen)
  384.                         Case 2 ; full path
  385.                                 $sReturnFormat = $WorkFolder
  386.                 EndSwitch
  387.                 While 1
  388.                         $nMsg2 = GUIGetMsg()
  389.                         Switch $nMsg2
  390.                                 Case $Go
  391.                                         $interrupt = True
  392.                                         ExitLoop
  393.                                 Case Else
  394.                                         $file = FileFindNextFile($search)
  395.                                         If @error Then ExitLoop
  396.                                         If @extended Then ; Folder
  397.                                                 If $sExcludeFolder And Not StringRegExp($file, $sExcludeFolder) Then ContinueLoop
  398.                                                 If $bRecursive Then
  399.                                                         If $aQueue[0] = $iQMax Then
  400.                                                                 $iQMax += 128
  401.                                                                 ReDim $aQueue[$iQMax + 1]
  402.                                                         EndIf
  403.                                                         $aQueue[0] += 1
  404.                                                         $aQueue[$aQueue[0]] = $WorkFolder & $file & "\"
  405.                                                 EndIf
  406.                                                 If $iFlag = 1 Then ContinueLoop
  407.                                                 $sRet &= $sReturnFormat & $file & "|"
  408.                                         Else ; File
  409.                                                 If $iFlag = 2 Then ContinueLoop
  410.                                                 If $sInclude And Not StringRegExp($file, $sInclude) Then ContinueLoop
  411.                                                 If $sExclude And Not StringRegExp($file, $sExclude) Then ContinueLoop
  412.                                                 $sRet &= $sReturnFormat & $file & "|"
  413.                                         EndIf
  414.                         EndSwitch
  415.                 WEnd
  416.                 FileClose($search)
  417.                 If $interrupt Then ExitLoop
  418.         WEnd
  419.         If Not $sRet Then Return SetError(4, 4, "")
  420.         Return StringSplit(StringTrimRight($sRet, 1), "|")
  421. EndFunc   ;==>_FileListToArrayPlus
« Last Edit: July 20, 2020, 07:06 PM by 4wd »

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #8 on: June 23, 2012, 01: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.


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,386
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #9 on: June 23, 2012, 02:42 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. :)

2012-06-23_17-41-48.jpg

See above for archive.

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

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #10 on: June 23, 2012, 03: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://networkadmink...ortcuts-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.



skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,208
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #11 on: June 23, 2012, 08:16 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?

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,386
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #12 on: June 24, 2012, 01:33 AM »
OK, I was bored so I thought I'd have a play around and came up with BSM, (guess what that stands for).

2012-07-09_20-21-43.jpg

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.  :)

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 AM by 4wd »

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #13 on: June 24, 2012, 03:32 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.



nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #14 on: June 24, 2012, 03:45 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.


nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #15 on: June 25, 2012, 11:09 AM »

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

DONE!


lujomu

  • Member
  • Joined in 2008
  • **
  • default avatar
  • Posts: 40
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #16 on: June 25, 2012, 04:46 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!

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #17 on: June 25, 2012, 04:53 PM »

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


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,386
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #18 on: June 25, 2012, 09:27 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).

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #19 on: July 08, 2012, 03:00 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.


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,386
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #20 on: July 08, 2012, 05:36 AM »
It won't work due to a slight oversight on my part  :-[

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:
2012-07-08_21-10-51.jpg

And this is what you'll get:
2012-07-08_21-11-05.jpg

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 AM by 4wd »

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #21 on: July 08, 2012, 11:38 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.



nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #22 on: July 08, 2012, 11:46 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.



4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,386
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #23 on: July 09, 2012, 01:31 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 ? 2012-07-09_16-30-06.jpg

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):

2012-07-09_16-01-54.jpgDONE: Batch adjust shortcut targets

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

2012-07-09_16-06-56.jpgDONE: Batch adjust shortcut targets

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

2012-07-09_16-08-29.jpgDONE: Batch adjust shortcut targets


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

See what I can do.

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 AM by 4wd »

nkormanik

  • Participant
  • Joined in 2010
  • *
  • Posts: 442
    • View Profile
    • Donate to Member
Re: DONE: Batch adjust shortcut targets
« Reply #24 on: July 09, 2012, 01:57 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!