for..each statement in CLI
I'd like to create a CLI batch file doing something like this:
For Each <file> in <directory> Do {} But i don't know how. Anyone? |
there's no such way
use spat, it's kind of similar: performs a command on a pattern of files for recursivity, you have to use a recursive dir and rework the output to generate a temp script file that you execute. you can install the amiga version of sed, cut, etc... to help you with the replacements. clumsy! i dunno about python on the classic amigas, but python just rules compared to all other scripting languages. even perl and bash don't stand a chance against it. as for stuff i know of, there are implementations of csh and ksh (pdksh). I used the latter but proved kind of instable. |
Quote:
Code:
list >ram:script "<directory>" files lformat="<your_command> *"%p%n*"" For example: Code:
list >ram:script Work: all dirs lformat="if not exists *"%p%n.info*"*n copy envarc:Sys/def_drawer.info *"%p%n.info*"*nendif" |
There are a couple of "foreach" programs on Aminet: http://aminet.net/search?query=foreach that might be useful?
I remember using foreach.lha in some scripts with DirOpus with good results. :) |
Thomas, that worked like a charm!
Thanks!!! By the way, I found AmigaPython which should do the trick as well. |
Is there any way to do the following:
Code:
For each file named "foo" in this folder and all its subfolders do: I didn't try the "foreach" programs until now, but I'm not sure they can filter files by name from all subdirectories. Any ideas how to write this? Thanks :) |
The list command has an "ALL" option which recursively scans subdirectories as well.
|
Thanks Thomas. Yes, that's what I thought too.
But "list foo all" lists all files of the directories named foo. What I'd need: List all files named foo in all the subdirectories. (Example case: 200 directories, some of them contain the file foo) |
list all files p=foo
|
When I was previously looking for a foreach command I found:
http://aminet.net/package/util/cli/finkelshelltoo |
Hey guys,
Quote:
For further reference: Create a script with "command path/name" of all filtered filenames (including subfolders): Code:
list >ram:script1 all files p=name1 lformat="command *"%p%n*"" Code:
list >ram:script1 all files p=name1 lformat="protect *"%p%n*" +s" |
All times are GMT +2. The time now is 19:57. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.