Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy text to clipboard using batch script

I would want to copy a text to the clipboard using batch script so I don't have to open a text file to select all text and copy. I tried this code:

echo | set /p= hello & echo.world |clip

Output

world

Expected clip (desired)

hello
world

but it only clipped:

world

What are options so I can copy and paste multiple line text or paragraph using batch file? Thanks!

like image 591
Rap God Avatar asked Sep 16 '25 23:09

Rap God


1 Answers

Like Nico wrote, if you have several lines of text, then you’ll need to wrap them in brackets () like this:

echo off | clip
(
echo This is line one
echo This is line two
echo this is line three
)| clip

More information about it you can find here.

like image 194
Iczko Avatar answered Sep 19 '25 15:09

Iczko