I am trying to copy the folder structure of SOURCE Folder to TARGET Folder including sub-folders (empty and non-empty), without copying the Files themselves, instead I want to create file shortcuts of all files in their respective folders in the TARGET folder Structure.

I have tried this, and successfully created folder Structure:


But I am unable to find an option to create file Shortcuts (.lnk files)for respective files in TARGET folder source

Pictorial representation of SOURCE and TARGET Folders

  • Why do they have to be lnk files and not just links? Creating lnk files can be quite difficult and your problem is likely pretty unique. Have a look at How to make a shortcut from CMD? to find some information about how to create lnk files using a script. You will likely have to write a script your own to do this. With PowerShell you could use something like Get-ChildItem -Recurse -File. – Seth Aug 14 '18 at 11:26

This PowerShell Function would do the trick.

Save it anywhere as Create-ShortcutForEachFile.ps1

load it into a PowerShell session like this: . C:\somewhere\Create-ShortcutForEachFile.ps1

Then use it like this: Create-ShortcutForEachFile -Source C:\foo -Destination C:\bar -Recurse

function Create-ShortcutForEachFile {


    # set recurse if present
    if ($Recurse.IsPresent) { $splat = @{ Recurse = $true } }

    # Getting all the source files and source folder
    $gci = gci $Source @splat
    $Files = $gci | ? { !$_.PSisContainer }
    $Folders = $gci | ? { $_.PsisContainer }

    # Creating all the folders
    if (!(Test-Path $Destination)) { mkdir $Destination -ea SilentlyContinue > $null }
    $Folders | % {
        $Target = $_.FullName -replace [regex]::escape($Source), $Destination
        mkdir $Target -ea SilentlyContinue > $null

    # Creating Wscript object
    $WshShell = New-Object -comObject WScript.Shell

    # Creating all the Links
    $Files | % {
        $InkName = "{0}.lnk" -f $_.BaseName
        $Target = ($_.DirectoryName -replace [regex]::escape($Source), $Destination) + "\" + $InkName
        $Shortcut = $WshShell.CreateShortcut($Target)
        $Shortcut.TargetPath = $_.FullName

protected by Community Jun 20 at 22:31

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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