Re: Linux to Batch


Subject: Re: Linux to Batch
From: David J. Weller-Fahy (largely@innocent.com)
Date: Thu Oct 17 2002 - 02:52:10 AKDT


> Using the folling as an example from Horde:
> for foo in *.dist; do cp $foo `basename $foo .dist`; done
>
> Does anyone know how I might do the same thing in a Dos batch script?
> I first need to detect if there is more than one file in a directory,
> I then need to move those files one at a time to be processed.

Hmmm... I don't think that you need to determine the number of files in
the directory, as long as the batch file iterates through 1 or more
files. If I'm wrong, somebody let me know. Anyway, here's what I came
up with on google.

This one is generally about FOR:
http://gatsby.tafe.tas.edu.au/batch/html/for.html

This one talks about using FOR...IN...DO loop to replace "DIR /B":
http://gatsby.tafe.tas.edu.au/batch/html/faq.html#12

The example in the latter link should work, just make sure that there
are no directories in the folder where the files are. Or, if they all
will have the same extension, just use '*.whatever' instead of '*.*'.

Probably easiest to have two batch files. First one would iterate
through the list of files (as in the above link), and call the second
batch file which would perform whatever operations you wanted done.

Of course, this would work as well (batch file called 'do_stuff.bat'):

#v+
@echo off
 if not "%1" == "" goto do_stuff_here
 for %%f in (*.*) do call %%f
 goto end

:do_stuff_here
 move %%f c:\processhere\%%f

:end
#v-

HTH,

  dave

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Thu Oct 17 2002 - 02:52:14 AKDT