How to copy files pointed to (not the shortcut files themselves)

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.

1

12 Answers

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!

1

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.

2

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

It's straightforward in PowerShell.

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

(modified from )

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
}

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.

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%"
1

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

1

Other possibility: there is the utility ShortcutsToClipboard.exe:

  1. Copy the utility into the folder that has the shortcuts.
  2. Run it. This will copy the shortcuts' targets into the clipboard.
  3. Navigate with Explorer to the target directory and press Ctrl-V or "Rightclick > Insert".
  4. Copying is executed

(Original source of information)

In my previous reply. I mentioned that back in the 1990's, Aladdin made a PC version of Dropstuff which made both "zip" and "sit" compressed archives. Believe it or not, I still have a Windows 98 computer that has version 5.0 of Aladdin Dropstuff installed on it. Like the ancient Mac version, this PC version allows you to select as a preference, whether the link it was given should be put into the archive or the original file that the link points to. Unfortunately, there are some issues. First, one of keyboard short-cuts for this program is ctrl+z which might interfere with what ctrl+z is supposed to do in other programs. Second, if you install this on a Windows 7 computer, it is not clear how well it will co-exist with the compressed "zip" file handling that is now built in to Windows (Windows 95 and 98 did not have this capability). In any case, once the files you want are in the "zip" archive that Aladdin Dropstuff will make, it is a simple matter to get those files from that archive.

This is another variation on using Powershell to do the job. I mostly copied this from somewhere, but I forgot where:

$wshShell = New-Object -ComObject wscript.shell
$LinksFolder = 'D:\mydirectory'
$DestFolder = 'L:'
$wshShell = New-Object -ComObject wscript.shell
gci $LinksFolder '*.lnk' -recurse | Foreach{ $Source = Get-item ($wshShell.CreateShortcut($_.FullName)).TargetPath #change the extension to match source. Hopefully there's no extra '.lnk' in the name $Destination = Join-Path $DestFolder $_.Name.Replace(' - Shortcut.lnk','') Copy-Item $Source $Destination #Add the -Whatif option show what it would have done (but don't do it)
}
Write-Host -NoNewLine 'Done. Press any key to exit...';
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');

As noted above, you can change the Windows execution policy if necessary to run this, but if you do change it, definitely make sure to change it back (set to "default") when you're done. Otherwise it could be a huge security hole.

I know you said Windows XP, Vista or 7, but back in the 1990's in Mac OS 7, you could tell Aladdin's DropStuff software (by checking a box in the preferences) to Stuff the Original files instead of the Aliases (shortcuts) when creating a "sit" (similar to a "zip") compressed archive. Back in those days, there was a free PC version of Aladdin's software that made "zip" archives. It ran on Windows 95 and 98. Perhaps it will run on Windows XP, Vista or 7 and allow you to do the same thing there.

Download XYplorer for Windows.
Right click on shortcuts and select

Shortcut target -> Copy shortcut item target

and enjoy ;)

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like