In the folder E:\Files there are 2 files, which I want to copy and paste into D:\Dest:
Using the keyboard I would simply select the 2 files, push ctrl+c, and in the destination folder D:\Dest\ I then push ctrl+v.
Now I want to achieve this using Powershell. So I copy the files into the clipboard:
Set-Clipboard -Path E:\Files\*
But how to paste those files now into the destination folder? Obviously, I will need
Get-Clipboard. But it’s not quite clear to me, how to use it, in order to paste the files.
I know I could copy the contents of these 2 files and then by using
Set-Content create those files in D:\Dest\ on my own and copy the content into them. But is there any direct way? Because with
Set-Clipboard those files already are in the clipboard. They just need to be pasted. I can use ctrl+v and it works. But I want to paste them through Powershell. Any ideas?
Here’s the script I use to paste files/directories:
$fileDrop = get-clipboard -Format FileDropList
if($fileDrop -eq $null)
write-host "No files on the clipboard"
foreach($file in $fileDrop)
$source = join-path $file.Directory $file.Name
$e = "copy-item -Recurse $source $($file.Name)"
$file | copy-item