Copy file to Clipboard using Powershell

Asked

Viewed 647 times

4

What command should I use through Powershell to send a file to Clipboard?

I’ve tried this command: "C: Teste.text" | Set-Clipboard

But this command copies the text "C: Test.text" and not the file to memory.

3 answers

2

I think this will solve your problem ;)

Set-Clipboard -Path C:\NomeArquivo.txt

1

I believe the simplest way is to use the commands type and clip:

type C:\NomeArquivo.txt|clip
  • Hello Gomiero, I just tried your suggestion and only the file name was for the Clipboard and not the file itself. My need is to copy the file and not the string containing its name. Anyway thank you very much for the help!

  • I did a test here, and copied the contents of the file in Powershell and even at the "normal" Windows prompt (cmd). Appeared some error message?

  • Maybe, this other answer: How to list folder files on the network may also help

  • 1

    @Diegofelipe I don’t understand. The question isn’t how to copy the contents of the file to the Clipboard? Please advise me if you do not agree with the command used in the answer, and I can delete it without any problems.

  • @Gomiero Scupe, I was wrong in the analysis, ignore the automatic comment.

  • @Diegofelipe Ok! Thanks for the return :-)

Show 1 more comment

0

About which of the options is the question? Archive? or Content?

  • 1) Copy the Own Archive (copy and paste filing cabinet)

  • 2) Copy the Contents of the Archive (Copy and paste contents)


  • For shares of copy/paste the filing cabinet to the ClipBoard (Crtl+C) already aiming at stick together (or rename it/paste) in another place...


1) Copies the file itself to the Clipboard enabling renaming or not:

# copia o arquivo para o ClipBoard # 
  Get-ChildItem Q115551.log | Set-Clipboard 

# ou via uso de alias # 
  ls Q115551.log | scb

# Colar o arquivo na pasta apontada pela variável %temp% com o nome "Colado.log" #
  Get-Clipboard -Format FileDropList | Copy-Item -Destination $env:temp\Colado.log -PassThru

# ou via uso de alias #  
  gcb -Format FileDropList | cpi -Destination $env:temp\Colado.log -PassThru


  • For shares of copy/paste only the contents of the archive to the ClipBoard (Crtl+C), and in this action, already aiming stick together that contents in another filing cabinet...


2) Copies the contents of the file to the Clipboard

# copiar o conteúdo do arquivo para o ClipBoard (Crtl+C) # 
  Get-Content Q115551.log | Set-Clipboard

# ou via alias # 
  gc Q115551.log | scb

# para colar o conteúdo do arquivo num destino #
  ForEach-Object {Get-Clipboard} $_ | Set-Content $env:temp\Colado2.log 

# ou via alias # 
  % $_ {gcb} $_ | sc $env:temp\Colado2.log



  • To only display/print on the screen the contents of ClipBoard (Crtl+C)

# para copiar o conteúdo do arquivo e listar na tela #
  Get-Content Q115551.log | Set-Clipboard ; ForEach-Object {Get-Clipboard} $_

# ou via alias #
  gc Q115551.log | scb ; % $_ {gcb} $_ 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.