havakok
havakok

Reputation: 1247

Pipeline in CMD. Passing the output of first command as the first argument of the second command

I want to pipeline to a copy operation. For example if we look at the command:

copy a.txt b.txt

I want to get "a.txt" from the former operation that is (as I have tried and failed):

echo a.txt| copy b.txt

I know this is not the correct syntax and I am failing (after a long google search) to understand what is the correct syntax to pass the output of the former command as the first argument of the second command.

How do I pipe this?

Upvotes: 0

Views: 412

Answers (1)

Compo
Compo

Reputation: 38579

Well apart from the fact replacing an image with a text file is a poor idea, this is all you need from the command line. (There is no requirement for a pipe).

For /F "EOL=H Tokens=2*" %A In ('REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General" /v WallpaperSource') Do @Copy /Y "b.txt" "%~B">Nul

I would guess that you'll need to change "b.txt" accordingly.

Edit

Your updated command from a batch file:

@Echo Off
For /F "EOL=H Tokens=2*" %%A In (
    'REG QUERY "HKCU\Software\Microsoft\Internet Explorer\Desktop\General"^
 /V WallpaperSource') Do Copy /Y "%%~B" "backup%%~xB">Nul

Upvotes: 1

Related Questions