1.

Solve : need help: How to write a batch to combine more 100 text files to one text file??

Answer»

Quote from: HELPMEH on December 15, 2009, 06:58:16 PM

Hey bill, try reading next time.

I meant to say I could not get the following code to work on my machine:

echo off
for /l %%a in (0,1,ENDNUMBER) do type file%%a.txt >> endresult.txt

The solutions offered here on the Hope Board are not just for the Original poster.  Many readers can often use the information.

I wonder if Helpme can show us the output for:

echo off
for /l %%a in (0,1,ENDNUMBER) do type file%%a.txt >> endresult.txt

Must we offer a new "ENDNUMBER" each time we run the code?

I use XP.  Will the above code run for XP?

An example of the Output of all code offered will help the OP plus the readers.

Thank you Helpmeh  for your time and effort.


You replace ENDNUMBER with the number in the last file. The OP perfectly understood, and it seemed very obvious to replace it.
And no, I can not run it, as I am not on a computer. what bill (or joan or liz or mike or ??) meant is OP won't know the ENDNUMBER before hand unless he can find out from dir *.txt and change the code. Its probably BETTER not to use the for loop range + step method, but just use the output from dir file*.txt
Code: [Select]for .... (dir file*.txt) do (
  type .... >> output.txt
)
how about this? counts txt files. i found this code somewhere off the forums a while ago, it was in my batch bank

replace the "set I=1" for the number the file sequence starts

Code: [Select]echo off
:recurse
set I=1

cd
FOR /f "tokens=*" %%P IN ('dir /A-d /B *.txt') do (call :showfiles "%%P")
echo.
echo Filecount: %I%

for /l %%a in (0,1,%I%) do type file%%a.txt >> endresult.txt
:showfiles
echo %1
set /a I+=1
goto :eof Quote from: BatchFileBasics on December 15, 2009, 08:17:51 PM
how about this? counts txt files. i found this code somewhere off the forums a while ago, it was in my batch bank

replace the "set I=1" for the number the file sequence starts

Code: [Select]echo off
:recurse
set I=1

cd
FOR /f "tokens=*" %%P IN ('dir /A-d /b *.txt') do (call :showfiles "%%P")
echo.
echo Filecount: %I%

for /l %%a in (0,1,%I%) do type file%%a.txt >> endresult.txt
:showfiles
echo %1
set /a I+=1
goto :eof

why not just do dir file*txt ? there's no need to call another loop to count total files. Of course, unless there other files with names like filetest.txt , fileblahblah.txt and you want to isolate those that have numbers following "file", which you could do that with dir file*txt | findstr /I "file[0-9]*.txt" Quote from: BatchFileBasics on December 15, 2009, 08:17:51 PM
how about this? counts txt files. i found this code somewhere off the forums a while ago, it was in my batch bank

replace the "set I=1" for the number the file sequence starts

Code: [Select]echo off
:recurse
set I=1

cd
FOR /f "tokens=*" %%P IN ('dir /A-d /b *.txt') do (call :showfiles "%%P")
echo.
echo Filecount: %I%

for /l %%a in (0,1,%I%) do type file%%a.txt >> endresult.txt
:showfiles
echo %1
set /a I+=1
goto :eof


Where is Output? Quote from: billrich on December 15, 2009, 09:18:42 PM

Where is Output?
Why don't YOU run it and put out any output it MAKES, instead of "Where is output?" over and over again. Sometimes you really sound like a broken record. Quote from: Helpmeh on December 16, 2009, 04:56:58 AM
Why don't YOU run it and put out any output it makes, instead of "Where is output?" over and over again. Sometimes you really sound like a broken record.

I don't think I WOULD have bought that record in the first place, let alone played it after it was broken. Anyhow, wasn't he banned? Why is he now unbanned?
Quote from: Salmon Trout on December 16, 2009, 05:08:00 AM
I don't think I would have bought that record in the first place, let alone played it after it was broken. Anyhow, wasn't he banned? Why is he now unbanned?

New name...lowercase b is all it takes. Quote from: Helpmeh on December 16, 2009, 07:08:38 AM
New name...lowercase b is all it takes.

-------------------------------------

Show your code and show output and stop faking it. Quote from: billrich on December 16, 2009, 02:51:16 PM
-------------------------------------

Show your code and show output and stop faking it.
1. I've shown my code, heck, YOU've even used it in your posts.
2. As I've said before, I don't have access to a computer. I am on my iPod.
3. How am I faking? Read the OP's post. The code worked great for him. Quote from: Helpmeh on December 16, 2009, 05:53:32 PM
Read the OP's post. The code worked great for him.

The problem is on my end.  I could not get the code to work on my machine.
I thought I could look at your code and output  and figure what I was doing wrong.

echo off
for /l %%a in (0,1,ENDNUMBER) do type file%%a.txt >> endresult.txt

I might try again.
Quote from: billrich on December 16, 2009, 06:08:13 PM
The problem is on my end.  I could not get the code to work on my machine.
I thought I could look at your code and output  and figure what I was doing wrong.

echo off
for /l %%a in (0,1,ENDNUMBER) do type file%%a.txt >> endresult.txt

I might try again.

Did you change ENDNUMBER? You haven't posted anything but a copypasta of my code. Post the code in YOUR batch file. Quote from: billrich on December 15, 2009, 09:18:42 PM

Where is Output?

why do i need output?I think bill is just frustrated because the code doesn't work for him. That happens to the best of us. We get impatient and angry.


Discussion

No Comment Found