- Option #1
Why not at the cmd/bat/commandline to run the one-line powershell command to do this...
1) Copy one or more files to ClipBoard
2) Set destination drive\folder: Copy-Item -Destination D:\Folder_Target
%temp% folder:powershell --NoProfile -command "Get-Clipboard -Format FileDropList | Copy-Item -Destination $env:temp"
powershell --NoProfile -command "Get-Clipboard -Format FileDropList | Copy-Item -Destination $env:temp"
powershell -nOp -c "gcb -Format FileDropList | cpi -Destination $env:temp -PassThru"
- Option #2
Where bat/cmd with c# paste the code, it will be compiled and executed at run time.
paste.bat D:\folder\target\/* & @cls & @echo off & title <nul & title %~nx0: Past File to: "%~1" & setlocal enabledelayedexpansion
2>nul >nul del /q /f "%tmp%\TSPaste2.exe" & for /f tokens^=* %%c in ('%__APPDIR__%where.exe /r "c:\Windows\Microsoft.NET" csc.exe
')do "%%~c" /t:exe /out:"%tmp%\TSPaste2.exe" "%~f0" /platform:anycpu /unsafe+ /w:0 /o /nologo && goto :next
echo/Error: Check/edit ccs.exe command line/flags^!! && endlocal && goto :EOF
:next
"%tmp%\TSPaste2.exe" "%~1" & del /q /f "%tmp%\TSPaste2.exe" & endlocal & goto :EOF && rem./ 2>nul >nul */
// C# code by @Andy Brown https://www.experts-exchange.com/
//
using System;
using System.IO;
using System.Windows.Forms;
namespace TSPaste2
{
class Program
{
//Getting destination foler :: note: from argument %~1 ::
String[] args = Environment.GetCommandLineArgs();
[STAThread] static void Main(string[] args)
{
//Setting Destination foler:
string DestFolder = args[0];
if (Clipboard.ContainsFileDropList())
{
//copy to D:\test ( note: note: C# args[0] == bat/cmd == "%~1" )
foreach (string source in Clipboard.GetFileDropList())
{
string Dest = DestFolder + "\\" + Path.GetFileName(source);
File.Copy(source, Dest, true);
}
}
}
}
}
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /t:exe out:"%tmp%\TSPaste2.exe" "%tmp%\TSPaste2.cs" /platform:anycpu /unsafe+ /w:0 /o nologo
csc.exe versions:c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe
c:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
c:\Windows\Microsoft.NET\Framework64\v2.0.50727\csc.exe
c:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe
command line used to compile the c# code:c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe /t:exe /out:"%tmp%\TSPaste2.exe" "%tmp%\TSPaste2.cs" /platform:anycpu /unsafe+ /w:0 /o /nologo
TSPaste2.exe C:\destination\folderTo keep the TSPaste2.exe compiled file, edit the code by adding this line in bold/italics:
:next
copy /y "%tmp%\TSPaste2.exe" "c:\some\folder"
"%tmp%\TSPaste2.exe" "%~1" & del /q /f "%tmp%\TSPaste2.exe" & endlocal & goto :EOF && rem./ 2>nul >nul */
Obs.: 1) c# code /by @Andy Brown / Experts-Exchange C Paste files from clipboard
Obs.: 2) c# code overwrites files, if they exist in the destination folder.
Read more: File.Copy Method