Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Append file1+literal+file2+literal? 1

Status
Not open for further replies.

SantaMufasa

Technical User
Jul 17, 2003
12,588
US
What syntax can I use, from the command prompt, to append file1+literal+file2+literal into a resulting_file?

I am familiar with this syntax:
Code:
copy file1+file2 file3
...but I would like to specify command-line literals before and after <file2>.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
Hi Mufasa

How about something like this:

Code:
@echo off
cls
echo Batch file to prompt for two inputs and then concatenate txt files
pause
set /p string1=Enter string #1:
set /p string2=Enter string #2:
echo %string1%>temp1.txt
echo %string2%>temp2.txt
copy file1.txt + temp1.txt + file2.txt + temp2.txt output.txt
del temp1.txt
del temp2.txt
set string1=
set string2=
echo Terminating

Jock
 
Jock,

Thanks for heading me in the right direction. Hava
star.gif
for your great suggestion.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
“People may forget what you say, but they will never forget how you made them feel.
 
Here is a version with error detection and the names of the files on the command line, e.g. supercopy file1 text1 file2 text2 file3
Code:
@echo off
if not %5. == . goto is5
echo not enough parameters
goto end
:is5
if %6, == . goto not6
echo excess parameters
goto end
:not6
if exist %1 goto is1
echo %1 does not exist
goto end
:is1
if exist %3 goto is3
echo &3 does not exist
goto end
:is3
if not exist %5 goto not5
echo %5 already exists
goto end
:not5
copy %1 %5
echo %2 >> %5
copy %5 + %3
echo %4 >> %5
:end
echo Terminating
Note the proper syntax for the 2nd copy statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top