Welcome Guest.   Make a donation to an author on the site October 31, 2014, 03:25:28 AM  *

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 2010! Download 24 custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1] 2 Next   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: IDEA: Create shortcuts from a list  (Read 9631 times)
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« on: November 20, 2006, 10:08:37 PM »

sometimes i need to create quickly shortcuts but the right-click/drag-drop is a bit slow at times. i have a list which i would like a program to go through and create individual shortcuts for each item in the list.

so, i am wondering if there is a program that could create shortcuts (*.lnk) from a text list containing file and/or folder.. can anyone help me out?
« Last Edit: November 23, 2006, 11:18:13 AM by brotherS » Logged

mouser
First Author
Administrator
*****
Posts: 33,611



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: November 21, 2006, 12:22:43 AM »

if you can find a commandline program to make a single shortcut of a file, you could use my drag+drop robot to just paste your list of files in the file list and run it on all of them.
Logged
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #2 on: November 21, 2006, 07:49:24 PM »

ah, drag+drop robot.. good idea, mouser. thumbs up i all but forgot about it.. i think ddr needs more promotion, eh? anyway, i'll be needing a cmd-line *.lnk file maker first.
Logged

cranioscopical
Friend of the Site
Supporting Member
**
Posts: 4,182



see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #3 on: November 21, 2006, 10:28:57 PM »

Quote
i'll be needing a cmd-line *.lnk file maker

This any use?
http://www.ss64.com/nt/shortcut.html
Logged

Chris
mouser
First Author
Administrator
*****
Posts: 33,611



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: November 21, 2006, 10:45:54 PM »

nice find chris  thumbs up
Logged
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #5 on: November 21, 2006, 11:46:53 PM »

XXMKLINK also works similarly but after thinking about it, i kinda prefer a Gui-ish tool..
Logged

Ruffnekk
Honorary Member
**
Posts: 331



Uhm yeah...

View Profile WWW Give some DonationCredits to this forum member
« Reply #6 on: November 22, 2006, 06:20:27 AM »

sometimes i need to create quickly shortcuts but the right-click/drag-drop is a bit slow at times. i have a list which i would like a program to go through and create individual shortcuts for each item in the list.

so, i am wondering if there is a program that could create shortcuts (*.lnk) from a text list containing file and/or folder.. can anyone help me out?

Okay so what format is the text file in? Something like <full source path> <full destination path> <shortcut name> <icon source> ?? Or is the destination always the same folder or the desktop? A bit more info and I can create a quick tool for it I think.

Regards,
Ruffnekk
Logged

Regards,
RuffNekk

Programming is an art form that fights back.
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #7 on: November 22, 2006, 08:48:44 PM »

it's in plain-text file, something like a "dir /b" output.. additionally if i can specify shortcut name, then it's fine..
this is how the list looks like:
Logged

thesteve
Participant
*
Posts: 6

View Profile Give some DonationCredits to this forum member
« Reply #8 on: November 23, 2006, 12:30:46 AM »

@lanux128:

I'm a brandy-new member here, so please be tolerant of my ignorance of protocol.

I wrote a small VBScript that appears to suit your needs. I don't see a way to upload this to DonationCoder, and I should have been in bed hours ago so I'm not going to go and upload it to my website, so I've placed the source code inside the nifty code tags:
[copy or print]
'*********************************************
'** ShortcutCreator
'*********************************************
'** Author: Steve Perkins Date: 11/23/06
'** Purpose:
'**  This VBScript allows the user to
'**  specify a file containing paths to
'**  shortcuts and possibly shortcut names and
'**  creates shortcuts on the user's desktop
'**  according to the specifications.
'**
'** REQUIREMENTS:
'**  You must have Windows Script Host installed
'**  (http://www.microsoft.com/downloads/details.aspx?FamilyId=C717D943-7E4B-4622-86EB-95A22B832CAA&displaylang=en
'**  OR http://browse.files.filefront.com/Windows+Script+Windows+v560/;1652432;/browsefiles.html
'**  if you don't want to validate your copy of Windows).
'**
'** USAGE:
'**  Open a command prompt and type wscript ShortcutCreator.vbs /file:[shortcutDataFile.txt].
'**
'** NOTES:
'**  With this utility you can either let the program
'**  figure out shortcut display names or specify
'**  them in the file. If you do not specify shortcut
'**  names, this script will strip the filename
'**  from the path the shortcut points to and remove
'**  the file extension and use the remainder as
'**  the shortcut's display name.
'**  IF YOU WANT TO SPECIFY SHORTCUTS NAMES, put them
'**  after the path of the shortcut, separating the ]
'**  two values with a comma.
'**  EXAMPLE: C:\Program Files\Fortitude.exe, Fortitude Shortcut
'**
'**  You can specify some shortcuts with display names
'**  and some without in the same data file.
'**
'**  This script has no useful comments. It was put together
'**  specifically for a user on DonationCoder.com.
'*********************************************

Dim shortcut_file

Set args = WScript.Arguments.Named

shortcut_file = args.Item("file")

If shortcut_file = "" Then
Wscript.Echo "Usage: ShortcutCreator.vbs /file:filepath"
Else
Dim objFSO, objTextFile, WshSysEnv, sh
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(shortcut_file, 1, False)
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("PROCESS")
dim root
root = WshSysEnv("USERPROFILE")

Set sh = WScript.CreateObject("WScript.Shell")
Do Until objTextFile.AtEndOfStream
Dim file_name
Dim shortCutName
Dim splut
Dim pos, array_len
shortCutPath = objTextFile.ReadLine
splut = Split(shortCutPath, ",")
array_len = UBound(splut)

If array_len > 0 Then
shortCutPath = splut(0)
End If
If array_len >= 1 Then
shortCutName = splut(1)
file_name = shortCutName
Else

pos = Len(shortCutPath) - InStrRev(shortCutPath, "\")
file_name = Right(shortCutPath, pos)

pos = Len(file_name) - 4
file_name = Left(file_name, pos)
shortCutName = file_name
End If

Set shortCutLink = sh.CreateShortcut(root & "\Desktop\" & shortCutName & ".lnk")
shortCutLink.TargetPath = shortCutPath
shortCutLink.WindowStyle = 1

shortCutLink.Description = file_name
shortCutLink.Save
Loop

objTextFile.Close
WScript.Echo("Finished.")
End If

I don't know how familiar you are with WSH and VBScript, so a quick instruction guide:
1. Copy the code I've presented to you and paste it into a new text document.
2. Rename the text document with a .vbs extension.
3. Run the little snot from the command line using the syntax wscript [whatever].vbs /file:[directory\]shortcutPathsFile.txt

I won't check back until after Thanksgiving, so if you have questions I'll be glad to answer them then.
Logged
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #9 on: November 23, 2006, 12:54:16 AM »

welcome aboard, thesteve!
don't worry about protocols.. the folks here at DC are very tolerant & forgiving.. Wink
your script looks cool.. i'm gonna try this out later today and will let you know if it works for me..

thanks again! Thmbsup
Logged

Ruffnekk
Honorary Member
**
Posts: 331



Uhm yeah...

View Profile WWW Give some DonationCredits to this forum member
« Reply #10 on: November 23, 2006, 01:24:13 AM »

Nice script thesteve, similar to what I had in mind. I have a remark though, possibly a typo or a potential bug:

The statements If array_len > 0 Then and If array_len >= 1 Then are identical in this context. Therefore the statement shortcutName = splut(1) might throw an IndexOutOfRangeException. I think the code should be corrected to If array_len > 1 Then for the second If ... Then clause.
Logged

Regards,
RuffNekk

Programming is an art form that fights back.
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #11 on: November 23, 2006, 07:56:57 PM »

thesteve: your script works fine! thumbs up

but being on the look-out for a gui tool, i was wondering is it possible to:
• have a tiny window that supports drag-n-drop.
• set the output (shortcuts) to be created in the current folder, i.e. the folder that the text file resides.
• have an exe file of this script for computers that don't have Windows Script.

also to Ruffnekk: tks for the info. will keep that in mind, in case i run into errors..
Logged

thesteve
Participant
*
Posts: 6

View Profile Give some DonationCredits to this forum member
« Reply #12 on: November 23, 2006, 10:17:32 PM »

Nice catch, Ruffnekk. I suppose the If array_len > 0 should really be a check for null instead. Testing for array_len = 0 wouldn't work, unfortunately. If anyone has a more elegant way of doing the same task, please jump in.
Logged
Ruffnekk
Honorary Member
**
Posts: 331



Uhm yeah...

View Profile WWW Give some DonationCredits to this forum member
« Reply #13 on: November 24, 2006, 01:53:32 AM »

Can’t you just use splut.Length?
Logged

Regards,
RuffNekk

Programming is an art form that fights back.
thesteve
Participant
*
Posts: 6

View Profile Give some DonationCredits to this forum member
« Reply #14 on: November 24, 2006, 02:18:10 PM »

@Ruffnekk:
splut.Length returns an "Object required" error - though it's been a while since I've worked with VBScript, my thought (and some quick Google research) is that the Length property is available for strings, but not arrays. UBound([arrayname]) is the accepted way to find an array's length in VBScript. I believe IsNull() could be used to check for null values in the array.
Logged
skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #15 on: December 12, 2006, 02:48:02 AM »

smiley Here's a Gui version called Text2Shortcut.

It shows a little always on top window where you can drag and drop a text file containing lines of filenames. The shortcuts are placed on your desktop in the folder of the text file.

Save to Text2Shortcut.ahk, download and install AutoHotkey from www.autohotkey.com, run.

Skrommel


« Last Edit: December 21, 2006, 04:07:01 AM by skrommel » Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
skwire
Global Moderator
*****
Posts: 4,119



Another Coding Snack request? Om nom nom...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #16 on: December 12, 2006, 11:45:27 AM »

if you can find a commandline program to make a single shortcut of a file,

Here's one I've had in my toolkit forever called SLink.  I've attached it to this post.

[copy or print]
(skwire@hankoku 11:40:36)
Probe/ ~$slink
SLink  -  Command line Windows shortcut file creator
  2003(c) Stephane Grobety - Released under BSD license
Usage:
  Slink <source file name> [<target file name>]
  Slink -?
Parameters
  <source file name>: Source file. Can be a wild card
  <target file name>: Optional target name of the Shortcut.
  -?: This help text
If Source file name is a wild card, the target MUST be a folder.

* slink.zip (84.31 KB - downloaded 105 times.)
Logged

lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #17 on: December 12, 2006, 07:50:31 PM »

skrommel, good script but as stated earlier.. i'd like to set the output (shortcuts) to be created in the current folder, i.e. the folder that the text file resides or at least, be able to configure the output folder.
Logged

skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #18 on: December 13, 2006, 08:19:16 AM »

 tellme Of course! Try the script now, lanux128!

Skrommel
Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #19 on: December 17, 2006, 10:24:47 PM »

cool script, skrommel but as usual, more suggestions.. Wink
• i want to be able to specify shortcuts names, like the script by thesteve.
• in case of no shortcut names, remove the '.exe' from created shortcuts. (see item.1)
• more customizeable drop-box. i.e. remembers location & size. (item.2)
• right-click on drop-box to choose new output path or at least show a input-box for copy/paste the output path.

Logged

skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #20 on: December 18, 2006, 02:23:16 AM »

smiley How about this?

Now you can add the target path after the file in the text file, separated by a comma:
<source file>,<target folder> for example c:\boot.ini,c:\archive.
To change the default path, that is, override the path of the dropped text file, doubleclick in the drop window.
To remove the default path, just cancel the browse dialog.

Skrommel
« Last Edit: December 21, 2006, 04:05:55 AM by skrommel » Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #21 on: December 18, 2006, 09:34:37 PM »

thanks for the update, all the suggestions have been included & it works wonderfully.. thumbs up

however there's a small glitch, the output path thing doesn't work if there is a space in the path. i also tried enclosing it in quotes but no change, ditto for the shortcut name.. i'm also a bit hazy about the syntax, esp. the shortcut name, is it like the code below? smiley

Quote
<exe path>,<output path>,<link name>

Logged

skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #22 on: December 19, 2006, 09:31:39 AM »

 smiley No, it's <source file>,<target folder>
But <shortcut name> could be added, too.

Try the script above now. I've added "s in the shortcut creation.

Skrommel
Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
lanux128
Global Moderator
*****
Posts: 6,120



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #23 on: December 19, 2006, 08:19:34 PM »

smiley No, it's <source file>,<target folder>
But <shortcut name> could be added, too.
btw, is <target folder> compulsory? because the new script doesn't seem to work..

Try the script above now. I've added "s in the shortcut creation.
i think the quotation marks here somehow broke the script..

[copy or print]
..
    FileCreateShortCut,"%part_1%","%dir%\%name%.lnk"
  }
  Else
  If part_0=2
    FileCreateShortCut,"%part_1%","%part_2%.lnk"
..

only after removing the quotes, did the script work..
« Last Edit: December 19, 2006, 08:22:13 PM by lanux128 » Logged

skrommel
Fastest code in the west
Developer
***
Posts: 882



View Profile WWW Give some DonationCredits to this forum member
« Reply #24 on: December 20, 2006, 02:25:38 AM »

 smiley Got a bit carried away there, only the first "s are needed.

Is it still broken?

Skrommel
Logged

Please stop by my site at  1 Hour Software by skrommel  for downloads and more info.
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.052s | Server load: 0.03 ]