Please help me with a batch file.

  • Thread starter Thread starter Sandy Kaminski
  • Start date Start date
S

Sandy Kaminski

Hi, I am using MS Windows 2000. I need to write a batch file for video
encoding and I don't have any experience in writting Command prompt or batch
programs. Could you help me with this small batch program. Here is what I
want to do:
The video files to encode are in folder called: "inputfolder". The folder to
store files after they are encoded is called "outputfolder". There are 100
files to encode in "inputfolder". I want to write a batch that would encode
all 100 files in a loop. The name of each videofile in "inputfolder" differs
from one another with a number in the end of file name. For example:
videofile-1, videofile-2, videofile-3, videofile-4,...., videofile-100. I
wanted to put the encoding statements into a loop, and use the value of the
loop variable "AAA" (see below) to substitute for videofile number:
videofile-AAA.

1. Could you help me write a correct code to use in a batch file?

For AAA = 1 to 100
C:\program.exe -i X:\inputfolder\videofile-"AAA".avi -o
X:\outputfolder\videofile-"AAA".avi
Next

2. Can you also tell me how to call this batch file from the command prompt
window?

Thank you very much for your help.

Sandy
 
While one could take the approach you describe it is easier to process all files in a directory.

For %%A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%%A" -o "X:\outputfolder\%%~nxA"

This should work but I can't test. Type For /? for help. The for command can count too so you can use it with your original approach.

Just type the full pathname to run the file. EG if you put it in C:

c:\mybatchfile.bat

Drag it into the command prompt or Start Run box and it will type the name for you.

You can skip the batchfile by placing this in a shortcut

cmd /k For %A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%A" -o "X:\outputfolder\%~nxA"

Note %A if typing or %%A if in a bat file. Change the /k to /c if you want the window to close when finished.

Type for /? and cmd /? for help (or look it up is Help and Support which is a bit more detailed).
 
Hi,
Thank you for your reply. I tested it, but I think that something is
missing. There is no error when I try to run the batch file, but it seems
that it is not being run at all. Do I need to assign a value to the %%A
variable? If yes, how to do that? I am sorry, I just don't know the command
prompt language at all:)


"David Candy" <.> wrote in message
While one could take the approach you describe it is easier to process all
files in a directory.

For %%A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%%A" -o
"X:\outputfolder\%%~nxA"

This should work but I can't test. Type For /? for help. The for command can
count too so you can use it with your original approach.

Just type the full pathname to run the file. EG if you put it in C:

c:\mybatchfile.bat

Drag it into the command prompt or Start Run box and it will type the name
for you.

You can skip the batchfile by placing this in a shortcut

cmd /k For %A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%A" -o
"X:\outputfolder\%~nxA"

Note %A if typing or %%A if in a bat file. Change the /k to /c if you want
the window to close when finished.

Type for /? and cmd /? for help (or look it up is Help and Support which is
a bit more detailed).
 
After I run the mybatchfile.bat, the command prompt returns the entire text
from the .bat file:
C:\DOCUME~1\ADMINI~1>For %A in (X:\Resampling\test\input\*.*) Do "C
:\Tools\Converter_5_0\Converter.exe" -i "%A" -o "X:\
Editing\output\%~nxA"

Is there anything missing in the batch file? The way I did the batch file, I
just created .txt document (later renamed it to .bat), entered nothing else
but this:
For %A in (X:\Resampling\test\input\*.*) Do
"C:\Tools\Converter_5_0\Converter.exe" -i "%A" -o "X:\
Editing\output\%~nxA"

...and I run it from teh command prompt window by typing: X:\mybatchfile.bat.
the .bat file is on my drive called X


"David Candy" <.> wrote in message
While one could take the approach you describe it is easier to process all
files in a directory.

For %%A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%%A" -o
"X:\outputfolder\%%~nxA"

This should work but I can't test. Type For /? for help. The for command can
count too so you can use it with your original approach.

Just type the full pathname to run the file. EG if you put it in C:

c:\mybatchfile.bat

Drag it into the command prompt or Start Run box and it will type the name
for you.

You can skip the batchfile by placing this in a shortcut

cmd /k For %A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%A" -o
"X:\outputfolder\%~nxA"

Note %A if typing or %%A if in a bat file. Change the /k to /c if you want
the window to close when finished.

Type for /? and cmd /? for help (or look it up is Help and Support which is
a bit more detailed).
 
You seem to be running it in command.com. Type cmd in Start Run then type

For %A in (X:\Resampling\test\input\*.*) Do "C:\Tools\Converter_5_0\Converter.exe" -i "%A" -o "X:\Editing\output\%~nxA"

Not having your program makes it hard to test but this does work
for %A in (c:\windows\*.exe) do copy "%A" "c:\%~nxA"

and you get one line like this per file
C:\Documents and Settings\David Candy>copy "c:\windows\explorer.exe" "c:\explore
r.exe"
 
...And If I try to enter the entire statement directly to command prompt
window, my computer starts beeping and does not let me enter more
characters, just as if it didn't want to accept such a long statement. This
is why I decided to use .bat file and just execute it from the command
window.

"David Candy" <.> wrote in message
While one could take the approach you describe it is easier to process all
files in a directory.

For %%A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%%A" -o
"X:\outputfolder\%%~nxA"

This should work but I can't test. Type For /? for help. The for command can
count too so you can use it with your original approach.

Just type the full pathname to run the file. EG if you put it in C:

c:\mybatchfile.bat

Drag it into the command prompt or Start Run box and it will type the name
for you.

You can skip the batchfile by placing this in a shortcut

cmd /k For %A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%A" -o
"X:\outputfolder\%~nxA"

Note %A if typing or %%A if in a bat file. Change the /k to /c if you want
the window to close when finished.

Type for /? and cmd /? for help (or look it up is Help and Support which is
a bit more detailed).
 
Hey, ITS WORKING!!!
I forgot to put the video files into the folder:)

THANK YOU VERY MUCH!!!

"David Candy" <.> wrote in message
While one could take the approach you describe it is easier to process all
files in a directory.

For %%A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%%A" -o
"X:\outputfolder\%%~nxA"

This should work but I can't test. Type For /? for help. The for command can
count too so you can use it with your original approach.

Just type the full pathname to run the file. EG if you put it in C:

c:\mybatchfile.bat

Drag it into the command prompt or Start Run box and it will type the name
for you.

You can skip the batchfile by placing this in a shortcut

cmd /k For %A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%A" -o
"X:\outputfolder\%~nxA"

Note %A if typing or %%A if in a bat file. Change the /k to /c if you want
the window to close when finished.

Type for /? and cmd /? for help (or look it up is Help and Support which is
a bit more detailed).
 
It actually worked with the .bat file fine. I just forgot to put the video
files to convert into the folder. THANK YOU SO MUCH!!!

"David Candy" <.> wrote in message
You seem to be running it in command.com. Type cmd in Start Run then type

For %A in (X:\Resampling\test\input\*.*) Do
"C:\Tools\Converter_5_0\Converter.exe" -i "%A" -o "X:\Editing\output\%~nxA"

Not having your program makes it hard to test but this does work
for %A in (c:\windows\*.exe) do copy "%A" "c:\%~nxA"

and you get one line like this per file
C:\Documents and Settings\David Candy>copy "c:\windows\explorer.exe"
"c:\explore
r.exe"
 
Brilliant! So brilliant, in fact, that I provided a nearly identical
solution in another newsgroup where the OP cross-posted.

/Al


"David Candy" <.> wrote in message
While one could take the approach you describe it is easier to process all
files in a directory.

For %%A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%%A" -o
"X:\outputfolder\%%~nxA"

This should work but I can't test. Type For /? for help. The for command can
count too so you can use it with your original approach.

Just type the full pathname to run the file. EG if you put it in C:

c:\mybatchfile.bat

Drag it into the command prompt or Start Run box and it will type the name
for you.

You can skip the batchfile by placing this in a shortcut

cmd /k For %A in (X:\inputfolder\*.*) Do "C:\program.exe" -i "%A" -o
"X:\outputfolder\%~nxA"

Note %A if typing or %%A if in a bat file. Change the /k to /c if you want
the window to close when finished.

Type for /? and cmd /? for help (or look it up is Help and Support which is
a bit more detailed).
 
Back
Top