Shortcut to create a link file in the opposite pane?
Moderators: fgagnon, nikos, Site Mods
Shortcut to create a link file in the opposite pane?
I have the focus on a file or folder in the left pane. I would like to create a short file, i.e. a .lnk file, in the right pane to the file I am focused on in the left hand pane?
I can right click and drag to the right pane and create shortcut.
Is there a menu or shortcut command to do this?
I can right click and drag to the right pane and create shortcut.
Is there a menu or shortcut command to do this?
Re: Shortcut to create a link file in the opposite pane?
Just looked and I couldn't see any way to assign this to a button. Note though: that Holding down Alt then dragging the item to the other pane seems to create an Lnk.rumsfeld wrote:Is there a menu or shortcut command to do this?
Re: Shortcut to create a link file in the opposite pane?
This would be nice! I love using F5 and F6 to copy/move. Shortcuts are a natural progression.rumsfeld wrote:Is there a menu or shortcut command to do this?
DOH!!!! <facepalm> :roll:
There is an actual "Paste Link" Command in the Edit menu... I looked right at it and didn't see it. This means that a person can probably do what the OP wants by using Snakebyte's Menu++ gizmo.
Edit: Okie dokie then, so if you install Snakebyte's free x2 tool that he made, and follow the directions to install it, then you could use the suggestion below:
=====================
First you have to go to the Customize menu and assign a hotkey to the Paste Link command. For the example below, I assigned Alt+L.
=====
THis assumes that both panes are showing. The side with the source file is active, and the source file is highlighted/selected. The target location is in the other pane:
Title='Paste Link to Other Side'
Action=send,^c,{Tab},!l,{Tab}
DisableIfNoSelections=0
=====
If the target location is always the same folder, then we can bookmark it and assign a hotkey to the bookmark. This example has Ctrl+4 as the hotkey. This assumes that there is only one pane open, the one with the source file. The source file is highlighted/selected and this Menu++ command opens the bookmarked folder and pastes and link to the source file.
Title='Open Bookmark 4 in, and Paste Link to, Other Side'
Action=send,^c,^o,{Tab},+^4,!l,{Tab}
DisableIfNoSelections=0
There is an actual "Paste Link" Command in the Edit menu... I looked right at it and didn't see it. This means that a person can probably do what the OP wants by using Snakebyte's Menu++ gizmo.
Edit: Okie dokie then, so if you install Snakebyte's free x2 tool that he made, and follow the directions to install it, then you could use the suggestion below:
=====================
First you have to go to the Customize menu and assign a hotkey to the Paste Link command. For the example below, I assigned Alt+L.
=====
THis assumes that both panes are showing. The side with the source file is active, and the source file is highlighted/selected. The target location is in the other pane:
Title='Paste Link to Other Side'
Action=send,^c,{Tab},!l,{Tab}
DisableIfNoSelections=0
=====
If the target location is always the same folder, then we can bookmark it and assign a hotkey to the bookmark. This example has Ctrl+4 as the hotkey. This assumes that there is only one pane open, the one with the source file. The source file is highlighted/selected and this Menu++ command opens the bookmarked folder and pastes and link to the source file.
Title='Open Bookmark 4 in, and Paste Link to, Other Side'
Action=send,^c,^o,{Tab},+^4,!l,{Tab}
DisableIfNoSelections=0
If one finds Kunk's solution a bit weird-looking or confusing , this can be done via windows script as well, more in the spirit of Nikos' blog.
Considering the myriad of ways Windows gives one of creating shortcuts, why anyone would want to take up toolbar space with it is beyond me, however, it's pretty easy, and if nothing else serves as a "lite" example of how to integrate script into x2, beyond what is possible with menu commands.
Copy the following and create a file called Shortcut.vbs (placed somewhere such as "C:\Scripts", or somesuch)
Then, create a User Command with the following:
> C:\Windows\System32\wscript.exe "C:\Scripts\Shortcut.vbs" "$F" "$I"
(Be sure to replace C:Scripts with wherever you placed the VBS file)
Add to toolbar, salt to taste, et voilà.
One benefit might be to supply automatic custom arguments (link.Arguments =) but how useful this might be in the long run is questionable.
Considering the myriad of ways Windows gives one of creating shortcuts, why anyone would want to take up toolbar space with it is beyond me, however, it's pretty easy, and if nothing else serves as a "lite" example of how to integrate script into x2, beyond what is possible with menu commands.
Copy the following and create a file called Shortcut.vbs (placed somewhere such as "C:\Scripts", or somesuch)
Code: Select all
Set objFSO = CreateObject("Scripting.FileSystemObject")
strTarget = Wscript.Arguments(0)
strFolder = objFSO.GetParentFolderName(strTarget)
strTargetName = Wscript.Arguments(1) & "\" & objFSO.GetFileName(strTarget) & ".lnk"
Set Shell = CreateObject("WScript.Shell")
Set link = Shell.CreateShortcut(strTargetName)
link.Arguments = ""
link.Description = ""
link.HotKey = ""
link.IconLocation = strTarget
link.TargetPath = strTarget
link.WindowStyle = "1"
link.WorkingDirectory = strFolder
link.Save
> C:\Windows\System32\wscript.exe "C:\Scripts\Shortcut.vbs" "$F" "$I"
(Be sure to replace C:Scripts with wherever you placed the VBS file)
Add to toolbar, salt to taste, et voilà.
One benefit might be to supply automatic custom arguments (link.Arguments =) but how useful this might be in the long run is questionable.
Last edited by Kilmatead on 2010 Oct 15, 23:27, edited 1 time in total.
What doesn't make sense? The script requires two arguments and simply makes a shortcut of the file (first parameter) in the folder which is the second parameter. The parameters are provided by the x2 user command tokens $F (selected file) and $I (inactive pane path).
Windows script can be infinitely useful, and a little more flexible (precise) than relying upon menu commands alone.
...and in case you were being facetious, "^c,{Tab},!l,{Tab}" isn't exactly Esperanto.
Windows script can be infinitely useful, and a little more flexible (precise) than relying upon menu commands alone.
...and in case you were being facetious, "^c,{Tab},!l,{Tab}" isn't exactly Esperanto.
-
- Bronze Member
- Posts: 106
- Joined: 2004 Jul 11, 14:55
One small suggestion for the VBS script file: Change "GetBaseName" to "GetFileName". This will make your shortcut, if it is a file, appear with its Extension, like Windows does when you use the Right-Click-Mouse-Drag and select "Create Shortcuts here"; for example, "Shortcut.lnk" will become "Shortcut.vbs.lnk".
Or, is there a downside to doing this that I am not seeing...
Or, is there a downside to doing this that I am not seeing...
Ah, yes, that's probably better for general use - my mistake - I had adapted the above quickly from a script I wrote to insert items directly into the start menu, and used basename to eliminate the superfluous ".exe", which everyone edits out later anyway .
Thanks. (Change reflected above.)
(Which, incidentally, examples one of the benefits of using VBS - one has control over the end result - if one really wanted to get carried away you could add in a whole InputBox() thing to verify the desired name before the shortcut is even created. But that might be a bit much for something so trivial - like I said, given how Windows almost makes it a mantra in its religion ("Thou shalt create shortcuts everywhere, damn it") I find it weird that anyone would want to use this anyway. But, two requests is more than one sceptic in the wilderness, so it's there to play with. )
...and before some wacky voice from the great beyond squeaks up and asks "How do I do that?", replace the line "strTargetName =" with:
Thanks. (Change reflected above.)
(Which, incidentally, examples one of the benefits of using VBS - one has control over the end result - if one really wanted to get carried away you could add in a whole InputBox() thing to verify the desired name before the shortcut is even created. But that might be a bit much for something so trivial - like I said, given how Windows almost makes it a mantra in its religion ("Thou shalt create shortcuts everywhere, damn it") I find it weird that anyone would want to use this anyway. But, two requests is more than one sceptic in the wilderness, so it's there to play with. )
...and before some wacky voice from the great beyond squeaks up and asks "How do I do that?", replace the line "strTargetName =" with:
Code: Select all
strTargetname = InputBox("Verify", "Shortcut Name", objFSO.GetFileName(strTarget))
If (strTargetName = "") then wscript.quit
strTargetName = Wscript.Arguments(1) & "\" & strTargetName & ".lnk"
-
- Bronze Member
- Posts: 106
- Joined: 2004 Jul 11, 14:55
Actually, thank you very much for including this code snippet. Added to your previous code, this changed the script into something very useful for my esoteric needs.
At work I maintain a local "Current Jobs" directory containing "shortcuts" to various jobs that I work on, jobs which are spread out in directories over several network drives, each with cryptic directory names. This modified script automates what has been a manual process of creating the shortcut and then renaming it to something more descriptive of the job.
Again, thanks.
At work I maintain a local "Current Jobs" directory containing "shortcuts" to various jobs that I work on, jobs which are spread out in directories over several network drives, each with cryptic directory names. This modified script automates what has been a manual process of creating the shortcut and then renaming it to something more descriptive of the job.
Again, thanks.
Ok, it seems I underestimated people's interest in esoterica. As per a couple of PM'ed user-requests, the script will now create shortcuts for all selected files, not just a single one (in keeping with what happens when you Right-Click-Drag multiple selections). It works for single items as well, and works fine with paths which include spaces (for those concerned).
For those who want the Name query box, just remove the comment (" ' ") from the strTargetname = InputBox() line. If the user clicks 'Cancel' (or edits out the name) the script will still cycle through the rest of the selected files, merely skipping those cancelled.
The User Command token format has changed as well, now use:
> C:\Windows\System32\wscript.exe "C:\Scripts\Shortcut.vbs" "$I" $A
I really wouldn't have thought anyone would think this useful, originally. Live and learn.
For those who want the Name query box, just remove the comment (" ' ") from the strTargetname = InputBox() line. If the user clicks 'Cancel' (or edits out the name) the script will still cycle through the rest of the selected files, merely skipping those cancelled.
Code: Select all
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")
for param = 1 to Wscript.Arguments.Count - 1
strTarget = Wscript.Arguments(param)
strTargetName = objFSO.GetFileName(strTarget)
strFolder = objFSO.GetParentFolderName(strTarget)
' strTargetname = InputBox("Shortcut Name", "Verification", strTargetName)
If (strTargetName <> "") then
strTargetName = Wscript.Arguments(0) & "\" & strTargetName & ".lnk"
Set link = Shell.CreateShortcut(strTargetName)
link.Arguments = ""
link.Description = ""
link.HotKey = ""
link.IconLocation = strTarget
link.TargetPath = strTarget
link.WindowStyle = "1"
link.WorkingDirectory = strFolder
link.Save
end if
next
> C:\Windows\System32\wscript.exe "C:\Scripts\Shortcut.vbs" "$I" $A
I really wouldn't have thought anyone would think this useful, originally. Live and learn.