Discussion:
looking for a code to add data
(too old to reply)
Dee
2009-04-22 11:06:03 UTC
Permalink
Hi

I'm looking for a sample code to add some small amount of repeated data
before and after some names in a text file.

Example

the list is

a
b
c
d


I want to add

test a today
test b today
test c today
test d today


any pointers would be great

D
--
Dee
T Lavedas
2009-04-22 12:37:44 UTC
Permalink
Post by Dee
Hi
I'm looking for a sample code to add some small amount of repeated data
before and after some names in a text file.
Example
the list is
a
b
c
d
I want to add
test a today
test b today
test c today
test d today
any pointers would be great
D
--
Dee
Try something like ...

@echo off
if '%1'=='' (echo Input file name missing. & goto :eof)
(for /f "delims=" %%a in (%~1) do echo test %%a today) >
"%~1.out.txt"

This will process the input file into an output file having two
additional extensions added to its name, ".out.txt". The input file
name is provided on the command line as an input.

Type FOR /? at a command prompt for more information on the syntax.

Tom Lavedas
***********
http://there.is.no.more/tglbatch/
Dee
2009-04-22 12:51:01 UTC
Permalink
thanks, will give it a go
--
Dee
Post by T Lavedas
Post by Dee
Hi
I'm looking for a sample code to add some small amount of repeated data
before and after some names in a text file.
Example
the list is
a
b
c
d
I want to add
test a today
test b today
test c today
test d today
any pointers would be great
D
--
Dee
Try something like ...
@echo off
if '%1'=='' (echo Input file name missing. & goto :eof)
(for /f "delims=" %%a in (%~1) do echo test %%a today) >
"%~1.out.txt"
This will process the input file into an output file having two
additional extensions added to its name, ".out.txt". The input file
name is provided on the command line as an input.
Type FOR /? at a command prompt for more information on the syntax.
Tom Lavedas
***********
http://there.is.no.more/tglbatch/
Dee
2009-04-22 14:07:01 UTC
Permalink
It worked a treat, thanks again
--
Dee
Post by Dee
thanks, will give it a go
--
Dee
Post by T Lavedas
Post by Dee
Hi
I'm looking for a sample code to add some small amount of repeated data
before and after some names in a text file.
Example
the list is
a
b
c
d
I want to add
test a today
test b today
test c today
test d today
any pointers would be great
D
--
Dee
Try something like ...
@echo off
if '%1'=='' (echo Input file name missing. & goto :eof)
(for /f "delims=" %%a in (%~1) do echo test %%a today) >
"%~1.out.txt"
This will process the input file into an output file having two
additional extensions added to its name, ".out.txt". The input file
name is provided on the command line as an input.
Type FOR /? at a command prompt for more information on the syntax.
Tom Lavedas
***********
http://there.is.no.more/tglbatch/
T Lavedas
2009-04-22 16:58:36 UTC
Permalink
Post by Dee
It worked a treat, thanks again
--
Dee
Post by Dee
thanks, will give it a go
--
Dee
Post by T Lavedas
Post by Dee
Hi
I'm looking for a sample code to add some small amount of repeated data
before and after some names in a text file.
Example
the list is
a
b
c
d
I want to add
test a today
test b today
test c today
test d today
any pointers would be great
D
--
Dee
Try something like ...
 if '%1'=='' (echo Input file name missing. & goto :eof)
 (for /f "delims=" %%a in (%~1) do echo test %%a today) >
"%~1.out.txt"
This will process the input file into an output file having two
additional extensions added to its name, ".out.txt".  The input file
name is provided on the command line as an input.
Type FOR /? at a command prompt for more information on the syntax.
Tom Lavedas
***********
http://there.is.no.more/tglbatch/
You're welcome. Thanks for the feedback.

Tom Lavedas
***********
http://there.is.no.more/tglbatch/

Loading...