How to write a bat script

How to write a bat script

Post by thierr » Tue, 19 Aug 2003 07:50:23



Hello,

I would like to write a bat script which would do this :

for i in d:/toto/*.txt; do erase $i done
then I would like to erase all files which have the txt extension in the
current directory where
is executed the .bat

thanks in advance
sincerely
t

 
 
 

How to write a bat script

Post by Timo Sal » Tue, 19 Aug 2003 08:30:06



> I would like to write a bat script which would do this :

 http://www.uwasa.fi/~ts/http/http2.html#batch

 235279 Dec 17 2002 ftp://garbo.uwasa.fi/pc/link/tsbat.zip
 tsbat.zip Useful batch files and tricks, linked from /pc/ts, T.Salmi

   All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa

Timo's  FAQ  materials  at   http://www.uwasa.fi/~ts/http/tsfaq.html

 
 
 

How to write a bat script

Post by Charles Dy » Tue, 19 Aug 2003 09:36:23


On Mon, 18 Aug 2003 00:50:23 +0200, "thierry"


>Hello,

>I would like to write a bat script which would do this :

>for i in d:/toto/*.txt; do erase $i done
>then I would like to erase all files which have the txt extension in the
>current directory where
>is executed the .bat

Perhaps I'm missing something obvious, but why not simply:

   erase d:\toto\*.txt

Note that DOS shells typically use the backslash, not the
forward slash, as a path separator.

--

 
 
 

How to write a bat script

Post by thierr » Wed, 20 Aug 2003 00:53:09


yes of course I am stupid, it was too late yesterday.
But I confirm I need to launch a command for each text file in directory,
it is not erase but webalizer.
To sum up I would like to convert this linux script in a windows script :
for i in /etc/webalizer/*.conf; do webalizer -c $i; done

Thanks for helping

sincerly

t



> On Mon, 18 Aug 2003 00:50:23 +0200, "thierry"

> >Hello,

> >I would like to write a bat script which would do this :

> >for i in d:/toto/*.txt; do erase $i done
> >then I would like to erase all files which have the txt extension in the
> >current directory where
> >is executed the .bat

> Perhaps I'm missing something obvious, but why not simply:

>    erase d:\toto\*.txt

> Note that DOS shells typically use the backslash, not the
> forward slash, as a path separator.

> --


 
 
 

How to write a bat script

Post by Vic Dur » Wed, 20 Aug 2003 06:14:12


On Mon, 18 Aug 2003 17:53:09 +0200,  RE: Re: How to write a bat script


>for i in /etc/webalizer/*.conf; do webalizer -c $i; done

The dos equivalent is

for %i  in  (\etc\webalizer\*.conf)  do webalizer -c %i

Note that webalizer must be in a directory listed in your PATH
statement.

 
 
 

How to write a bat script

Post by thierr » Wed, 20 Aug 2003 07:40:23




> On Mon, 18 Aug 2003 17:53:09 +0200,  RE: Re: How to write a bat script

> >for i in /etc/webalizer/*.conf; do webalizer -c $i; done

> The dos equivalent is

> for %i  in  (\etc\webalizer\*.conf)  do webalizer -c %i

> Note that webalizer must be in a directory listed in your PATH
> statement.

Thank you it works perfectly if I run from a dos console
for %i  in  (C:\webalizer\*.conf)  do webalizer -c %i
 but it does not work if I execute this command from a .bat file
in this case I got this error message
C:\webalizer\> weblog.bat
\webalizer\*conf> tait innatendu (was unexepected)

do you have any Ideas why I cannot run this command from a bat file whereas
the same command typed directly in a console dos
works ?

Thank you

sincerly
t

 
 
 

How to write a bat script

Post by Phil Roby » Wed, 20 Aug 2003 07:48:39





>>On Mon, 18 Aug 2003 17:53:09 +0200,  RE: Re: How to write a bat script

>>>for i in /etc/webalizer/*.conf; do webalizer -c $i; done

>>The dos equivalent is

>>for %i  in  (\etc\webalizer\*.conf)  do webalizer -c %i

>>Note that webalizer must be in a directory listed in your PATH
>>statement.

> Thank you it works perfectly if I run from a dos console
> for %i  in  (C:\webalizer\*.conf)  do webalizer -c %i
>  but it does not work if I execute this command from a .bat file
> in this case I got this error message
> C:\webalizer\> weblog.bat
> \webalizer\*conf> tait innatendu (was unexepected)

> do you have any Ideas why I cannot run this command from a bat file whereas
> the same command typed directly in a console dos
> works ?

> Thank you

> sincerly
> t

In a bat file, double the '%' signs

   for %%i in ... do webalizer -c %%i

--
Phil Robyn
Univ. of California, Berkeley

u n z i p   m y   a d d r e s s   t o   s e n d   e - m a i l

 
 
 

How to write a bat script

Post by thierr » Wed, 20 Aug 2003 07:58:07


Quote:> In a bat file, double the '%' signs

>    for %%i in ... do webalizer -c %%i

yes Thank you , I just found it before to read your post
ouf :)
 http://minilien.com/?COb57d5YZ0  at the end of the post

good night
t

 
 
 

1. WS_FTP.INI --> FTPSITES.HTM (4DOS script) - ftp2html.bat (0/1)

If anyone's interested, below is a 4DOS script that will look in ws_ftp.ini
for:

        [%name]
        HOST=%host
        UID=%uid
        DIR=%dir

and write a file, ftpsites.htm, of HTML anchors:

        <A HREF="ftp://%host">%name</A><BR>


The resulting file ain't pretty, but it is functional. If you have lots of
hosts listed in ws_ftp.ini (I have about 80) and you want to migrate those
connections to Netscape (or your favorite browser) this should save a lot of
work.

FTP2HTML.BAT expects to find (a copy of) ws_ftp.ini in the current
directory.

Long lines corrupted by the news-posting process may have to be fixed
manually before this batch program will run. I guess I'll also try
"attaching" a copy of it so that perhaps it won't have to be fixed up.

Customary disclaimers.

 - Vince



if %infile == -1 (echo Can't open ws_ftp.ini ^ quit)

if %outfile == -1 (echo Can't open ftpsites.htm ^ goto cleanup)
:findsect

if "%inline" eq "**EOF**" goto cleanup


:gotsect


unset host >& NUL
unset dir >& NUL
unset uid >& NUL
:nextline

if "%inline" == "" goto endsect

nextline)



goto nextline
:endsect
iff "%uid" eq "anonymous" .and. "%dir" ne "" then

HREF="ftp://%host/%dir/">%name</A><BR>]
elseiff "%uid" eq "anonymous" .and. "%dir" eq "" then

elseiff "%uid" ne "anonymous" .and. "%dir" ne "" then


elseiff "%uid" ne "anonymous" .and. "%dir" eq "" then


else
endiff
goto findsect
:cleanup


unset infile outfile bracket name dir uid host nlen inline written >& NUL

2. HELP!! Indigo2 and NT4 workstation

3. Utility to convert DOS ".bat" files to UNIX shell scripts

4. TeX interpreter

5. Dos Bat script file to login, run, retreive,send data.

6. pointer to AMReport #1.19

7. bat script documentation?

8. Passing param from BAT file to SQL script

9. WS_FTP.INI --> FTPSITES.HTM (4DOS script) - ftp2html.bat (1/1)

10. shell script writing in DOS

11. Assembler written in Bash script language

12. Writing Install Script using xcopy