Batch creation and execution of batch files
I'm making a encoder that uses the windows media encoder 9 script. Currently it doesn't have batch encoding. But I have an idea, but can't quite figure out how to do it. I'd have the user add the information in the encoder, then the file name would go into a listbox, doing so would create a batch file with the encoding information in it. This would happen for all of the files the user would add to the batch. When the user clicks the encode button, the program would go down a list of created batch files,
executing them in sequence.
Re: Batch creation and execution of batch files
What part do you need help on?
To execute an external command, the intrinsic method is to use Shell, although there are API calls that work better such as the shell execute API.
The shell command looks like this (this would launch the Windows Calculator):
Code:
Dim ReturnVal
ReturnVal= Shell("C:\WINDOWS\SYSTEM32\CALC.EXE", 1)
Writing a batch file would be pretty easy using the Open command to write out a text file. In fact, you can have your first batch file call many of them and you won't have to worry about using API calls to wait for each process to end before launching the next one.
Re: Batch creation and execution of batch files
Well. There is gonna be very unique information in each batch file. I allready know how to create and execute a batch file. I just need a way to execute a series of batch files in sequence. I think a loop would do it. The batch files created don't need to be named anything speciffic. If I can get VB6 to see if the file name for the batch file allready exists and then add a 1 or a 2 after it. That would work. Doing what you just said would require me to know exactly what the user would be inputing and how many files they would want to encode and then pre scripting the actions. I want each file to have it's own batch file and then have vb6 excute them through a loop command.
Re: Batch creation and execution of batch files
If you know how to create batch files and execute them, then I would think you have everything you need to complete your project.
Is there a specific aspect of your project that you need help with?
Re: Batch creation and execution of batch files
Yes, how to loop mutiple execution of batch files.
Re: Batch creation and execution of batch files
Make a loop to loop a Shell command
Code:
FOR i = 1 to 10
Shell BatchExec(i) 'Just an example
NEXT i
BatchExec() is a Sting Array containing batch file names + with their full paths (optionally)
Re: Batch creation and execution of batch files
Thanks! That's what I needed! :D
Now I need to have a way to idientfy the batch file names when the user puts the information into the main program and presses a button.
Like:
{user presses button}
Batch file is created and numbered
File to be encoded is put into a list box
{repeat}
Re: Batch creation and execution of batch files using biterscripting
Chris,
Here is a script that will do what you are looking for. Let's say the encoder you are making can be run with the following command.
Code:
myencoder "input file name" "output file name"
"input file name" is of type *.mpg, output file name is of type *.avi. (These are all assumptions. Use double quotes around input arguments, because file names can contain spaces.)
Now, you want to run this for all *.mpg files in C:\folder1 and its subfolders. Here is the script that will do that.
Code:
# Script encode.txt
# Get a list of all .mpg files in C:\folder1.
var str list ; lf -r -n "*.mpg" "C:\folder1" > $list
# Process files one by one.
while ($list <> "")
do
# Get the next file from the list.
var str input_file, output_file ; lex "1" $list > $input_file
# input_file has extension .mpg. Create output_file name by
# replacing .mpg by .avi.
sal -p -c "^.mpg^l" ".avi" $input_file > $output_file
# At this point, the full path of input file is in $input_file. The full
# path of the output file is in $output_file. Convert using the encoder.
system myencoder ("\""+$input_file+"\"") ("\""+$output_file+"\"")
# We are using double quotes because files names may have spaces in them.
echo "SUCCESSFULLY CONVERTED FILE " $input_file
done
This script would do what you are looking for. The script is in biterscripting ( http://www.biterscripting.com ) . It is free.
When you get your encoder working, please post how to use your encoder in batch mode using a scripting lanaguage. A lot of people may be interested in your batch encoder - I have seen tons of questions posted on the net about batch encoding.
Randi