Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder containing shortcuts that point to files that are located in various directories and drives. I would like to copy the files pointed to (NOT the shortcut files themselves) to a single destination folder.

Is there a way in windows (XP, Vista, 7), file manager, or some utility I can use to do this?

I've heard you can do this with various multi-step custom scripts. However, I've heard rumors there is a one click way to do this without having to fabricate a custom script each time, where regardless where the shortcuts point to, I can select the group of shortcuts and do a copy operation that will grab the files they point to. Then, I can paste or otherwise put the actual files (not shortcuts) into one directory.

It would be very time consuming to manually find each file pointed to by a shortcut and one by one copy them to the target folder.

Note that I've seen this question asked before on the internet but haven't seen a good answer.

share|improve this question
    
use copylinktarget plugin for total commander. – user111518 Dec 30 '11 at 11:15

I think the answer is no because a shortcut is not really a symbolic link in the same way it is in linux. The concept of symbolic link was introduced as part of NTFS 5.0, but they apply to directories, not files. Things may have changed in windows 7, I admit to being clueless there. Shell-shocked has a good article on Windows Symbolic and Hard Links.

It would be cool to be proven wrong on this one, because this is a problem I would love to have a solution to at work!

share|improve this answer
    
Windows .lnk files are similar to Linux .desktop files, aren't they? – petersohn Apr 16 '10 at 6:50

I've found a very easy method of copying the files shortcuts are pointing to rather than the shortcuts themselves:
Add the selection of shortcuts to ZIP (via the shell extension). Then the original files automatically get zipped and not the shortcuts.
Extracting the content of the ZIP file into a location of your preference gets the job done perfectly and quickly.

share|improve this answer

As an alternative workaround, I found Microsoft Groove very helpful. Files can be dropped into a Groove workspace as a temporary placeholder (like a zip file). Then drag and drop the files from the Groove workspace onto the destination folder in Windows Explorer.

share|improve this answer

It's straightforward in PowerShell.

To copy the target of a Windows shortcut (*.lnk) using PowerShell

(modified from http://windowsitpro.com/powershell/working-shortcuts-windows-powershell)

1) Create the following file (Powershell script):

====== file Get-Shortcut.ps1============

begin

{
    $WshShell = New-Object -ComObject WScript.Shell;
}

process

{
    $WshShell.CreateShortcut($_)
}
====== end file Get-Shortcut.ps1============

2) set execution policy to run scripts

Various ways to do this. One method:

  • Run powershell as administrator

  • Set-ExecutionPolicy bypass

(when done, set it back, e.g. "Set-ExecutionPolicy Default")


3) Run this loop in PowerShell

foreach ($lnk in Get-ChildItem C:\FromDir\\*.lnk -ErrorAction SilentlyContinue | .\Get-Shortcut.ps1)

{

echo $lnk.targetpath 

copy $lnk.targetpath C:\ToDir

}
share|improve this answer

Hold down the [Ctrl] key. Click and drag what you want to copy.

share|improve this answer
    
This does not do what the original question asked for. – Heptite Aug 3 '14 at 19:31

You can also use the filemanager Total Commander and the plugin CopyLinkTarget to copy the link targets very easily.

share|improve this answer

I had a similar problem where by we had a tree structure of shortcuts. We wanted to copy the target files along side the shortcut.

Below is the VB Script. You can easily change the destination directory by changing the fp_des variable.

Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("Wscript.Shell")

function main()

    if Wscript.Arguments.Count = 0 then Wscript.Echo "Please pass path to folder to scan"

    Wscript.Echo "Getting list of all files..."
    set all_files = get_files(Wscript.Arguments(0),"lnk",Nothing)

    for each fp_sc in all_files.Items
        Set sc = shell.CreateShortcut(fp_sc)        

        fp_src = sc.TargetPath
        fp_des = fso.GetParentFolderName(fp_sc) & "\" & fso.GetFileName(fp_src)

        if not fso.FileExists(fp_src) then
            Wscript "ERROR: Failed to find: " & vbcrlf & fp_src
        elseif fso.FileExists(fp_des) then
            Wscript.Echo "Already exists: " & fso.GetFileName(fp_des)
        else
            Wscript.Echo "Copying: " & fso.GetFileName(fp_des)

            fso.CopyFile fp_src,fp_des
        end if
    next

end function

function get_files(fp_dir,ext,dic) 
    if dic is Nothing then set dic = CreateObject("Scripting.Dictionary")

    set fldr = fso.GetFolder(fp_dir)

    for each fl in fldr.Files
        if fso.GetExtensionName(fl) = ext OR ext = "" then
            dic.Add dic.Count, fl   
        end if
    next

    for each fl_child in fldr.SubFolders
        get_files fl_child,ext,dic
    next

    set get_files = dic
end function

main

Run using the following code

cscript.exe //nologo links_to_files.vbs "%path_to_root_dir%"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.