Batch scripting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an automated process produces many *.txt files in a specific folder.
It is continuos text which runs to 20 to 30 pages without page break. I want
a utility that I can run throgh batch process to insert a page break before
the word "Hello". So that every page is started fresh wherever it has "Hello"
word.
Any ideas to accomplish this task?
 
Galop said:
I have an automated process produces many *.txt files in a specific folder.
It is continuos text which runs to 20 to 30 pages without page break. I want
a utility that I can run throgh batch process to insert a page break before
the word "Hello". So that every page is started fresh wherever it has "Hello"
word.
Any ideas to accomplish this task?

You could use this batch file:
@echo off
for /F "tokens=*" %%* in ('type test.txt') do (
echo %%* | find /i "Hello" > nul && echo.>>test1.txt
echo %%* >> test1.txt
)

It has some restrictions:
- I expect it to take some time to run through 30 pages.
- It will trip over so-called "poison characters" such as
, <, &, ^, |.
A better way might be to use Google to look for a Command
Line text editor.
 
You could use this batch file:
@echo off
for /F "tokens=*" %%* in ('type test.txt') do (
echo %%* | find /i "Hello" > nul && echo.>>test1.txt
echo %%* >> test1.txt
)

Hi

I was wondering: in %%* , is * used as a normal variable or does it
have a particular "wildcard" meaning, related to "tokens=*" ?

I noticed the first part of the script

for /F "tokens=*" %%* in ('type test.txt') do echo %%*

seems to work the same way when using %%i as variable

e.g.

for /F "tokens=*" %%i in ('type test.txt') do echo %%i

Thank you

__

Marco Pesce - e-mail: marcopesce#tin.it
 
Marco Pesce said:
Hi

I was wondering: in %%* , is * used as a normal variable or does it
have a particular "wildcard" meaning, related to "tokens=*" ?

I noticed the first part of the script

for /F "tokens=*" %%* in ('type test.txt') do echo %%*

seems to work the same way when using %%i as variable

e.g.

for /F "tokens=*" %%i in ('type test.txt') do echo %%i

Thank you

%%i will grab only the first token on the line (usually the first word).
%%* will grab the whole lot.
 
Back
Top