I am trying to copy multiple file paths using "Set-Clipboard" command in PowerShell
Here is the code to copy multiple files that does not work
#Individual paths
$a = "C:\Users\me\test\test1.pdf"
$b = "C:\Users\me\test\test2.pdf"
$paths = '"' + $a + '"' + ', ' + '"' + $b + '"'
#Checking path
Write-Host $paths
#Copying to Clipboard
Set-Clipboard -Path $paths
But the following code works. The following code copies both "test1.pdf" and "test2.pdf" from their respective locations to clipboard
Set-Clipboard -Path "C:\Users\me\test\test1.pdf", "C:\Users\me\test\test2.pdf"
But when this string is generated by code, it does not work.
The following also works
Set-Clipboard -Path $a, $b
In my case, there are a lot of files to copy from different locations. So, I have to generate a string with paths separated by a comma.
Could someone point me in the right direction?
Or please suggest an alternate way to copy multiple file paths to clipboard. Thanks