Making a Windows Batch File

tatteredpotato

Diamond Member
Jul 23, 2006
3,934
0
76
I have 49 text files named:
results1.txt
results2.text
....
....
results50.txt

There is every file in between except results13.txt.

Pretty much I want to make a script that will make a new file that will just put the files together. I've found the "COPY" command should do this, however I'm running into some issues. First I assumed that the shell would run from the directory of the batch file, however that doesn't seem to be the case. My code looks something like this (I'll update when I get to work and have the actual code).

set number=1
set ext=.txt
set baseName=results
set outputFile=output.txt


:Loop
IF %number%==51 GOTO End
set currentFile=%baseName%%number%%ext%
IF EXISTS currentFile COPY outputFile+currentFile outputFile
set /a number=%number%+1

:End
pause



I did add the absolute path to the files useing something like "%~d0" as well. Is that the way I'm supposed to concatenate strings? Just %var1%%var2%....etc?

 

tatteredpotato

Diamond Member
Jul 23, 2006
3,934
0
76
Originally posted by: reefcrazed
I do this all the time. You really just do a
copy resu*.txt output.txt

Oh wow I was over-complicating that wasn't I? Thanks for the help, it seems to have worked like a charm!