Looping script several hundred times ?

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Looping script several hundred times ?
# 1  
Old 03-01-2013
Looping script several hundred times ?

Hi,

I need to get a script to run over 100 of different files in a folder.

The current input file is:
(However the input file has to change by one counter each loop of the script(e.g. 001, 002, 003...))
Code:
001.gif


At the end of the scrip the current output is:
Code:
001output.gif

It should also increase by 1 counter after each loop (to match the input files increase.

So after the script finished all gif files in the folder it should have produced as many XXXoutput.gifs as there were input gifs to begin with.
Since I can't state an exact number it should repeat this for all files in the folder.

Thanks in advance for any help.
# 2  
Old 03-01-2013
the following works in cygwin -

Code:
$ for  i in $(seq 10) ; do  printf "%03d\n" $i; done
001
002
003
004
005
006
007
008
009
010

# 3  
Old 03-01-2013
the problem is that I'm curently under Dos...

Thanks anyways.
# 4  
Old 03-01-2013
Well if you can't put a decent shell on there, this works
Code:
@echo off
for /L %%A in ( 0 5 100 ) do (
	if %%A GTR 99 ( 
		echo %%A
	) else ( 
		if %%A GTR 9 (
			echo 0%%A
		) else (
		         echo 00%%A
		)
	)
)
@echo on


Last edited by Skrynesaver; 03-01-2013 at 06:44 AM..
# 5  
Old 03-03-2013
Well I guess what I wanted was kinda hard to understand...

Let me explain in a better way.

Lets say we have the following:

Code:
convert 001.gif -crop 128x128+0+0 001cropped.gif

The thing I want now, is:

I want DOS to process this command and then change the number of both the "001.gif" and "001cropped".gif by 1 counter and repeat the command.

This step should be processed till dos can't find a matching XXX.gif in the folder to input anymore.

so it is:
process script
- increment numbers by 1 counter (002)
process script again (with new counters)
- increment numbers by 1 counter (003)
...

until the input file (lets say 558 for example) is no longer found and the script is terminated.

That would be exactly what I want.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Infinite looping in script

we have one script which we use to send mail in our environment. If we are giving correct attachment script runs fine but if we give a attachment name which is not present on server then this script go to infinite loop and causing all memory to be used. could any one please suggest me what is wrong... (2 Replies)
Discussion started by: anshu ranjan
2 Replies

2. Shell Programming and Scripting

Rsh stops working after a few hundred calls

There's probably a better way to do what I'm doing and if so, let me know an alternative. I have a script that runs rsh for every entry in a txt file to go get the file size off the remote server. I then compare the remote size with a local size. My script worked fine until recently when I... (2 Replies)
Discussion started by: olds97_lss
2 Replies

3. Shell Programming and Scripting

Looping in the shell script with help of script timer.

Hello Experts- We are facing some issues in the while loop script when we use the script time to decide whether to exist from the loop or continue. Below is the script SrcExitLoop="FALSE" Src_InitialStartTime=`date +%s` Src_StartTime=`date +%s` Src_NUM_ALERTS=0 TOTAL_ALERTS=`expr <SOME... (4 Replies)
Discussion started by: Amey Joshi
4 Replies

4. Shell Programming and Scripting

trouble looping in script

I am having problem looping this script I want to give the user option to decide if they want to continue after each entry but then also loop it back to beginning so they can more to content of there testcase they just created. I fam new to scripting so loops are little tricky for me. code I... (7 Replies)
Discussion started by: andrew.p.mcderm
7 Replies

5. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

6. Shell Programming and Scripting

Menu Script looping

Hi , I have a menu driven script as shown below echo "" echo "*** 1 - option 1 " echo "*** " echo "*** 2 - option 2 " echo "*** 3 - option 3 " ... (3 Replies)
Discussion started by: ultimatix
3 Replies

7. Shell Programming and Scripting

Help Looping through files in Vi Script

I am trying to write a script that loops through all the files in the current directory that end in '.slg.gz' and runs a parser on each file. Here is my code: #!/bin/bash FILES_HOME = 'dirname $0' for i in $(ls $FILES_HOME/.slg.gz$);do ./run-feature-parser $(i) > OUTPUT.csv done ... (1 Reply)
Discussion started by: kssteig
1 Replies

8. Shell Programming and Scripting

appending a line to the end of several hundred files

I have a bunch of files named publish.php within subdirs. I need to append a line at the end of each file. I thought I could do it with find and echo like this: find . -name publish.php -exec echo "<? include('path/to/file.php'); ?>" >> '{}' \; but that appends the line to a file named {}... (2 Replies)
Discussion started by: surroscape
2 Replies

9. Shell Programming and Scripting

Looping script with variables

If I have a file with a bunch of various numbers in one column, how can I make a script to take each number in the file and put in into a command line? Example: cat number_file 2 5 8 11 13 34 55 I need a loop to extract each of these numbers and put them into a command line... (1 Reply)
Discussion started by: jojojmac5
1 Replies

10. Shell Programming and Scripting

Looping a perl script in a shell script

I am trying to get the follow script to run in the background on the 'fly'. I can launch it via cron and it will run in the background. BUT when I launch it from the command line it will run in the foreground. I figure it has to do with the while loop I have, but I have no clue how I can run the... (8 Replies)
Discussion started by: edkung
8 Replies
Login or Register to Ask a Question