Copy Windows Shortcut Target Contents - Possible?

Hi

I have a folder with a whole load of shortcuts pointing to folders I want to back up, unusual way I know, but there is a reason why I need to do it this way.

Is it possible to get Directory Opus to copy the original folder (clearly its contents too) instead of the shortcut?

Thanks in advance.

Matt

It seems, there is no standard way, since this is an item of the "properties" dialog. You might find this link interesting, although i donĀ“t know if & how this
works on OSes others than Windows XP. Also, you need to backup your system &/or registry, because registry changes can mess up your computer, as you know.

[b]Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Find.Target]
@="&Find Target"

[HKEY_CLASSES_ROOT\Directory\shell\Find.Target\command]
@=""explorer.exe" /select,"%1""

[HKEY_CLASSES_ROOT*\shell]

[HKEY_CLASSES_ROOT*\shell\Find.Target]
@="&Find Target"

[HKEY_CLASSES_ROOT*\shell\Find.Target\command]
@=""explorer.exe" /select,"%1""[/b]

from:

msfn.org/board/topic/35034-a ... 2bafe66de8

I found a VBScript which is (nearly) able to do what you want.

Unfortunately it can only copy the targets of shortcuts to files. It's not working with shortcuts to folders which is what you asked for.
You'll get an error when trying it on Folder-Shortcuts.

Perhaps someone here can make it work with folders.
Would also be nice to have the Script within the Code of the Button abusing the rename function of DOpus.

For now you'll need to copy the Code to a Textfile and rename the file to "CopyShortcutTarget.vbs".
Then you can call the file with the following Command from a Button:

@nodeselect "Your Path \CopyShortcutTarget.vbs {filepath}

It will copy all selected files normally.
Shortcuts to files will not be copied, but there Targets.
Shortcuts to Folders and selected Folders will give an error.

I found the original Script here:
http://www.experts-exchange.com/articles/Programming/Languages/Visual_Basic/VB_Script/Script-to-copy-or-move-collection-of-selected-files-plus-shortcut-target-files-referenced-by-lnk.html

I extracted only what's needed to pass the Target Arguments to dopusrt.exe:

CopyShortcutTarget.vbs

[code]Option Explicit

Dim ARG()
Dim ARGS()
Dim i
Dim f
Dim FileName	
Dim FilePath
Dim fExt
Dim ifExt
Dim oSHLink
Dim target	
Dim WShell
Set WShell = Wscript.CreateObject("Wscript.Shell")

Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

For i = 0 to Wscript.Arguments.Count - 1
  'Enumerate the collection and provide details of each item
  Redim Preserve ARG(i)
  ARG(i) = Wscript.Arguments(i)

  'Obviously there are various ways to handle looking at the filesystem object properties...
  Set f = fs.GetFile(ARG(i))
  FileName=f.Name
  FilePath=f.Path

  'Transform List-Item Links into their actual targets
  fExt = Fs.GetExtensionName(ARG(i))

  ifExt = StrComp(fExt, "LNK", vbTextCompare)
  IF ifExt = 0 THEN
    set oSHLink = Wshell.CreateShortcut(FilePath)
    target = oSHLink.TargetPath
    Set f = fs.GetFile(target)

  End If

  'Recreate a new collection containing all hard targets (no links)
  Redim Preserve ARGS(i)
  ARGS(i) = f

Next

' Now send this off to "dopusrt.exe"
WShell.Run """C:\Programme\Directory Opus\dopusrt.exe"" /cmd Copy """ & Join(ARGS,""" """)
'Next

Set oSHLink = Nothing
Set fs = Nothing
Set WShell = Nothing
Wscript.Quit

[/code]

Another thing I found is "Shortcut.exe", a small commandline Tool which is able to read the target Path and Name from a shortcut:
http://www.optimumx.com/download/#Shortcut

The following command writes the Output to a Textfile like this: "TargetPathExtended=Path to File\Filename.ext".
If someone is writing a Script which reads the Output, strips "TargetPathExtended=" from it and passes what is left to DOpus similar to that what the above script is doing it should work with Files and Folders.

Shortcut.exe /f:"Shortcut.lnk" /a:q |Find "TargetPathExpanded" >C:\Temp\Shortcut.txt

@mattgorner:

I got the VBScript now working also with Shortcuts to Folders!

See this Thread for the solution:
[url]Problem with Button in "MS-Dos Batch" Mode]

Thanks Guys, will give it a shot