pdccs@unix.cis.pittsburgh.edu (Patrick Champion) (08/15/89)
Could anyone tell me of a public domain program that exists at simtel or clarkson that does the following. Apply a command line to every file in a directory. For example: util command @file.ext params @file.ext where @file.ext would be replaced by all files in the current directory with wildcards being valid, and params are other parameters that are used by whatever command you are applying the utility against. I would use this utility to periodically run a certain program on every *.pix file in my directory. Thank you Pat Champion
leonard@bucket.UUCP (Leonard Erickson) (08/19/89)
pdccs@unix.cis.pittsburgh.edu (Patrick Champion) writes:
< Could anyone tell me of a public domain program that exists at simtel
<or clarkson that does the following.
< Apply a command line to every file in a directory.
< For example:
< util command @file.ext params @file.ext
< where @file.ext would be replaced by all files in the current
< directory with wildcards being valid, and params are other
< parameters that are used by whatever command you are applying the
< utility against.
You already have a copy of this utility. It's called COMMAND.COM.
The FOR command fits your request perfectly:
FOR %a IN (list) DO command %a params
For your specific example:
FOR %a IN (*) DO command %a.pix params
Look it up in your DOS manual. It'll probably be buried in the section
on batch file commands.
--
Leonard Erickson ...!tektronix!reed!percival!bucket!leonard
CIS: [70465,203]
"I'm all in favor of keeping dangerous weapons out of the hands of fools.
Let's start with typewriters." -- Solomon Short
sdn@anyguay.acm.rpi.edu (Eric Roode) (08/20/89)
In article <1634@bucket.UUCP> leonard@bucket.UUCP (Leonard Erickson) writes: >pdccs@unix.cis.pittsburgh.edu (Patrick Champion) writes: > >< Apply a command line to every file in a directory. PC magazine published a utility at least a year ago (I don't remember the specific issue) called SWEEP that applied a command to the current directory and to all subdirectories under the current directory. If you can find out what issue it was, you've got the utility.
richard@pantor.UUCP (Richard Sargent) (08/22/89)
> From: sdn@anyguay.acm.rpi.edu (Eric Roode) > Message-ID: <6868@rpi.edu> > > In article <1634@bucket.UUCP> leonard@bucket.UUCP (Leonard Erickson) writes: > >pdccs@unix.cis.pittsburgh.edu (Patrick Champion) writes: > > > >< Apply a command line to every file in a directory. > > PC magazine published a utility at least a year ago (I don't remember the > specific issue) called SWEEP that applied a command to the current directory > and to all subdirectories under the current directory. If you can find out > what issue it was, you've got the utility. I have done this regularly from within DOS. Syntax? Try: c> for %f in (*.*) do your_command_line Double the % when used in a batch file. Of course, there are complications if your_command_line creates new files, converts *.old to *.new, you can't substitute alternate file name extensions. In cases like these, I simply use a "new" directory for the output files. Example: c> for %f in (*.old) do sed /this/that/ %f >..\new\%f I hope this helps. Richard Sargent Internet: richard@pantor.UUCP Systems Analyst UUCP: uunet!pantor!richard
ts@chyde.uwasa.fi (Timo Salmi LASK) (08/22/89)
In article <20.UUL1.3#5109@pantor.UUCP> richard@pantor.UUCP (Richard Sargent) writes: >> From: sdn@anyguay.acm.rpi.edu (Eric Roode) >> PC magazine published a utility at least a year ago (I don't remember the >> specific issue) called SWEEP that applied a command to the current directory >> and to all subdirectories under the current directory. If you can find out > >I have done this regularly from within DOS. Syntax? Try: >c> for %f in (*.*) do your_command_line Yes, certainly. But unless I have missed something essential in your thinking, this only works for the current directory. Sweep extends a command to the subdirectories, as well. Right? All the best, Timo ................................................................... Prof. Timo Salmi (Site 128.214.12.3) School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun
a563@mindlink.UUCP (Dave Kirsch) (08/26/89)
> john writes: > There was also a PD program floating around called "Global" which > does the same thing. I use it routinely to sort all my directories > with one command. > I use Norton's DiskSort program to sort my directories, it's a simple "ds en /s" (sort on the extensive field, then the name field and do all subdirectories). Fast and efficent. Dave: a563@mindlink.UUCP
john@wa3wbu.UUCP (John Gayman) (08/26/89)
In article <6868@rpi.edu>, sdn@anyguay.acm.rpi.edu (Eric Roode) writes: > In article <1634@bucket.UUCP> leonard@bucket.UUCP (Leonard Erickson) writes: > PC magazine published a utility at least a year ago (I don't remember the > specific issue) called SWEEP that applied a command to the current directory > and to all subdirectories under the current directory. If you can find out > what issue it was, you've got the utility. There was also a PD program floating around called "Global" which does the same thing. I use it routinely to sort all my directories with one command. John -- John Gayman, WA3WBU | UUCP: uunet!wa3wbu!john 1869 Valley Rd. | ARPA: john@wa3wbu.uu.net Marysville, PA 17053 | Packet: WA3WBU @ AK3P
abcscnuk@csuna.csun.edu (Naoto Kimura) (09/07/89)
In article <20.UUL1.3#5109@pantor.UUCP> richard@pantor.UUCP (Richard Sargent) writes: > >I have done this regularly from within DOS. Syntax? Try: > >c> for %f in (*.*) do your_command_line > >Double the % when used in a batch file. > >Of course, there are complications if your_command_line creates new files, >converts *.old to *.new, you can't substitute alternate file name extensions. >In cases like these, I simply use a "new" directory for the output files. > >Example: > >c> for %f in (*.old) do sed /this/that/ %f >..\new\%f > > >I hope this helps. > >Richard Sargent Internet: richard@pantor.UUCP >Systems Analyst UUCP: uunet!pantor!richard One problem... This will fail because DOS will try to open an unnamed file in the directory ..\new. Even if it did work, you'd only get the output of the last sed command. I discovered this about a year ago when I wanted to do something similar. You'll have to write a batch file to handle such things as redirection. For example, you want to do the following: FOR %i IN (0 1 2 3 4 5 6 7 8 9) DO Barf < data%i.old > data%i.new This will not result in what you'd expect. This will result in barf trying to read a file called data.new and output the result to data.old. You need to create a batch file UGH.BAT in some subdirectory which contains the following line: BARF < %1 > %2 Then you type the following at the command line: FOR %i IN (0 1 2 3 4 5 6 7 8 9) DO UGH data%i.old data%i.new Another warning to those who use batch files -- the output of a batch file cannot be redirected unless you run a child COMMAND.COM and redirect its output. Suppose you had a batch file, for example BASEBALL.BAT, and you wanted its output to go to a file called OUT. If you typed: BASEBALL > OUT you would end up with an empty file OUT, and all the output of BASEBALL.BAT will go to the screen. You have to do the following to get the desired result: COMMAND /C BASEBALL > OUT This problem caused me some headaches for a few hours. I had a collection of batch files that created smaller batch files, which then were in turn either chained to or executed under a child command processor. Sometimes the redirection seemed to work, and sometimes it didn't. It made a difference where I happened to run the batch files, as they didn't always use a full pathname to refer to each other. So sometimes, the EXE file would be executed, and other times a BAT would be called :-( Another thing to remember about running the command processor is NEVER redirect its input unless you are running a command from it !!!!! I did this one day, thinking that it would do the same as if I were on a UNIX system running bourne shell. It did what I expected, but unfortunately, it resulted in the parent COMMAND.COM trying to read from the input file I specified for the child COMMAND.COM. I basically had to reboot the computer. Of course, I'm sure most of you have already tried this. Equally annoying was the fact that even if you redirected the output of the GWBASIC interpreter, the screen would always be cleared, and the output would still go to the screen (of course you'd get what you expected in the file -- the output of the program) ! It seems that the BASIC interpreters almost completely ignore DOS's stdin and stdout file handles. I suppose it makes sense since they seem to ignore everything else about DOS. What annoyed me to no end was when I tried to send escape sequences to the ANSI driver, but couldn't. I even tried to open a file "CON" and send my escape sequences to that file, but BASIC just output to the "CON" device as if I was doing a plain PRINT statement to BASIC's standard output device. If you're wondering, I needed to do things like clear to end of page and clear to end of line, insert line, and delete line. I eventually had to get rid of the places where I would've used insert and delete line, and used a subroutine that output the appropriate number of spaces to clear to end of page or line. If you're wondering why I was doing stuff in BASIC, I was moving a program on a TRS-80 over to an IBM-PC -- the customer didn't want me to rewrite the program in some other language because BASIC was all they could understand :-(. I used to have similar complaints about Turbo Pascal, but Borland has fixed the problems with introduction of version 4.0. At least it doesn't try to second-guess what you want when you try to open a DOS device. //-n-\\ Naoto Kimura _____---=======---_____ (abcscnuk@csuna.csun.edu) ====____\ /.. ..\ /____==== // ---\__O__/--- \\ Enterprise... Surrender or we'll \_\ /_/ send back your *&^$% tribbles !!