topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Thursday March 28, 2024, 10:17 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: IDEA: Create shortcuts from a list  (Read 20318 times)

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
IDEA: Create shortcuts from a list
« on: November 20, 2006, 10:08 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 AM by brotherS »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Create shortcuts from a list
« Reply #1 on: November 21, 2006, 12:22 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.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Create shortcuts from a list
« Reply #2 on: November 21, 2006, 07:49 PM »
ah, drag+drop robot.. good idea, mouser. :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.

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: Create shortcuts from a list
« Reply #3 on: November 21, 2006, 10:28 PM »
i'll be needing a cmd-line *.lnk file maker

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

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Create shortcuts from a list
« Reply #4 on: November 21, 2006, 10:45 PM »
nice find chris  :up:

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Create shortcuts from a list
« Reply #5 on: November 21, 2006, 11:46 PM »
XXMKLINK also works similarly but after thinking about it, i kinda prefer a Gui-ish tool..

Ruffnekk

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 332
  • Uhm yeah...
    • View Profile
    • RuffNekk's Crypto Pages
    • Donate to Member
Re: Create shortcuts from a list
« Reply #6 on: November 22, 2006, 06:20 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
Regards,
RuffNekk

Programming is an art form that fights back.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Create shortcuts from a list
« Reply #7 on: November 22, 2006, 08:48 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:
List-of-files
C:\Tools\bintext.exe
C:\Tools\checkdotnet.exe
C:\Tools\CloseAll.exe
C:\Tools\Contig.exe
C:\Tools\cpuz.exe
C:\Tools\DAMN NFO Viewer.ico
C:\Tools\datestat.exe
C:\Tools\Dr.exe
C:\Tools\Flashpla.exe
C:\Tools\K-TaskMod.exe
C:\Tools\ListFonts.exe
C:\Tools\mplayerc.exe


thesteve

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Create shortcuts from a list
« Reply #8 on: November 23, 2006, 12:30 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:
'*********************************************
'** 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.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Create shortcuts from a list
« Reply #9 on: November 23, 2006, 12:54 AM »
welcome aboard, thesteve!
don't worry about protocols.. the folks here at DC are very tolerant & forgiving.. ;)
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:

Ruffnekk

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 332
  • Uhm yeah...
    • View Profile
    • RuffNekk's Crypto Pages
    • Donate to Member
Re: Create shortcuts from a list
« Reply #10 on: November 23, 2006, 01:24 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.
Regards,
RuffNekk

Programming is an art form that fights back.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #11 on: November 23, 2006, 07:56 PM »
thesteve: your script works fine! :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..

thesteve

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #12 on: November 23, 2006, 10:17 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.

Ruffnekk

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 332
  • Uhm yeah...
    • View Profile
    • RuffNekk's Crypto Pages
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #13 on: November 24, 2006, 01:53 AM »
Can’t you just use splut.Length?
Regards,
RuffNekk

Programming is an art form that fights back.

thesteve

  • Participant
  • Joined in 2006
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #14 on: November 24, 2006, 02:18 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.

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #15 on: December 12, 2006, 02:48 AM »
:) 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 AM by skrommel »

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #16 on: December 12, 2006, 11:45 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.

(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.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #17 on: December 12, 2006, 07:50 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.

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #18 on: December 13, 2006, 08:19 AM »
 :tellme: Of course! Try the script now, lanux128!

Skrommel

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #19 on: December 17, 2006, 10:24 PM »
cool script, skrommel but as usual, more suggestions.. ;)
• 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.

shortcut-creator.png

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #20 on: December 18, 2006, 02:23 AM »
:) 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 AM by skrommel »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #21 on: December 18, 2006, 09:34 PM »
thanks for the update, all the suggestions have been included & it works wonderfully.. :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? :)

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


skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #22 on: December 19, 2006, 09:31 AM »
 :) 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

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #23 on: December 19, 2006, 08:19 PM »
:) 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..

..
    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 PM by lanux128 »

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Create shortcuts from a list
« Reply #24 on: December 20, 2006, 02:25 AM »
 :) Got a bit carried away there, only the first "s are needed.

Is it still broken?

Skrommel