Search code examples
windowscmdcommand-linecommand-line-arguments

Append data from one file to another windows command line


I have 2 files as file1 and file2.

File1 has data as below.

$$NewParameter =

File2 has data as below

23/03/2020 14:34:21

I want result as below in file 1

$$NewParameter = '23/03/2020 14:34:21'

I have tried below command.

type file2.txt >> file1.txt

but it gives me expecyed result without single quotes.

Any help regarding this command would be helpful.

Regards,

Mahesh


Solution

  • not sure what your end goal really is, but this is the best I can think of without using a for loop and batch file.

    If you want the result on one line

    set /p one=<file1.txt & set /p two=<file2.txt & echo %one% '%two%'>File1.txt
    

    If you want the result on separate lines

    set /p two=<file2.txt & echo '%two%'>>file1.txt