Эта функция PowerShell сделает свое дело.
Сохраните его в любом месте как Create-ShortcutForEachFile.ps1
загрузить его в сеанс PowerShell , как . C:\somewhere\Create-ShortcutForEachFile.ps1
Затем используйте его следующим образом: Create-ShortcutForEachFile -Source C:\foo -Destination C:\bar -Recurse
function Create-ShortcutForEachFile {
Param(
[ValidateNotNullOrEmpty()][string]$Source,
[ValidateNotNullOrEmpty()][string]$Destination,
[switch]$Recurse
)
# 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
$Shortcut.Save()
}
}