Home All Groups Group Topic Archive Search About

looking for a code to add data

Author
22 Apr 2009 11:06 AM
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

Author
22 Apr 2009 12:37 PM
T Lavedas
On Apr 22, 7:06 am, Dee <D***@discussions.microsoft.com> wrote:
Show quoteHide quote
> 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/
Author
22 Apr 2009 12:51 PM
Dee
thanks, will give it a go
--
Dee


Show quoteHide quote
"T Lavedas" wrote:

> On Apr 22, 7:06 am, Dee <D***@discussions.microsoft.com> wrote:
> > 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/
>
Author
22 Apr 2009 2:07 PM
Dee
It worked a treat, thanks again
--
Dee


Show quoteHide quote
"Dee" wrote:

> thanks, will give it a go
> --
> Dee
>
>
> "T Lavedas" wrote:
>
> > On Apr 22, 7:06 am, Dee <D***@discussions.microsoft.com> wrote:
> > > 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/
> >
Author
22 Apr 2009 4:58 PM
T Lavedas
On Apr 22, 10:07 am, Dee <D***@discussions.microsoft.com> wrote:
Show quoteHide quote
> It worked a treat, thanks again
> --
> Dee
>
> "Dee" wrote:
> > thanks, will give it a go
> > --
> > Dee
>
> > "T Lavedas" wrote:
>
> > > On Apr 22, 7:06 am, Dee <D***@discussions.microsoft.com> wrote:
> > > > 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/

You're welcome.  Thanks for the feedback.

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