Results 1 to 8 of 8

Thread: Batch creation and execution of batch files

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    13

    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.

  2. #2
    Hyperactive Member Quiver318's Avatar
    Join Date
    Sep 2007
    Posts
    260

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    13

    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.
    Last edited by chrisyroid; Jun 19th, 2009 at 04:56 PM.

  4. #4
    Hyperactive Member Quiver318's Avatar
    Join Date
    Sep 2007
    Posts
    260

    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?

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    13

    Re: Batch creation and execution of batch files

    Yes, how to loop mutiple execution of batch files.

  6. #6
    Fanatic Member Dungeon Keeper's Avatar
    Join Date
    Mar 2008
    Posts
    590

    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)
    No, that wont do!

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    13

    Re: Batch creation and execution of batch files

    Thanks! That's what I needed!

    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}
    Last edited by chrisyroid; Jun 19th, 2009 at 07:18 PM.

  8. #8
    New Member
    Join Date
    Apr 2009
    Posts
    4

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width