Batch Loop Variables
Posted: 13 Feb 2010 11:22
Hello all!
I am trying to create a batch script which is waaaaaaaay more complex than I know how to code for... but I know it can be done somehow, so I hope one of you geniuses can help me.
I have a MySQL and file backup script which I use to copy/zip/ftp a selection of domains on my server. At the moment, I have to manually add a lot of code to a batch file each time I add a domain.
What I would like is to specifiy a variables section at the top of a batch file or in a new INI file that would loop through some variables and allow me to code the backup script.
For example, I could specifiy some variables such as:
Filename=Cheese.rar, Database=Cheese, Location=c:\cheese
Filename=Mice.rar, Database=Mouse, Location=c:\squeek
and so on....
Then, I would be able to add the actual code that performs the actions after this. For example, I will just use the echo command:
Echo You have backed up database: %database% and files located in %location% to an archive called %filename%
This would then be looped for every row of variables.
How could I achive a way to read the rows of data in to an array of variabes and then perform a loop?
Any help would be great!
Ian
I am trying to create a batch script which is waaaaaaaay more complex than I know how to code for... but I know it can be done somehow, so I hope one of you geniuses can help me.
I have a MySQL and file backup script which I use to copy/zip/ftp a selection of domains on my server. At the moment, I have to manually add a lot of code to a batch file each time I add a domain.
What I would like is to specifiy a variables section at the top of a batch file or in a new INI file that would loop through some variables and allow me to code the backup script.
For example, I could specifiy some variables such as:
Filename=Cheese.rar, Database=Cheese, Location=c:\cheese
Filename=Mice.rar, Database=Mouse, Location=c:\squeek
and so on....
Then, I would be able to add the actual code that performs the actions after this. For example, I will just use the echo command:
Echo You have backed up database: %database% and files located in %location% to an archive called %filename%
This would then be looped for every row of variables.
How could I achive a way to read the rows of data in to an array of variabes and then perform a loop?
Any help would be great!
Ian