Batch file help

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rampatt
Posts: 2
Joined: 21 Feb 2013 17:41

Batch file help

#1 Post by rampatt » 21 Feb 2013 17:48

Hi,

I have a compiled binary which allows me to drop a video file onto it and it then makes some small fixes to the file and then outputs a fixed file into the same folder as the original.

So I drag and drop abc.flv onto and it produces a second file called abc.fix.flv in the same folder as abc.flv

It only works with one file at a time and I was hoping to write a batch file which allowed me to drag multiple video files onto it and have them processed one after the other.

Thanks for any help.

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: Batch file help

#2 Post by mfm4aa » 21 Feb 2013 18:28

My suggestion:

Code: Select all

@echo off
:loop
if not "%1"=="" start /w "" "CompiledBinary.EXE" "%1"
shift
if not "%1"=="" goto :loop

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch file help

#3 Post by foxidrive » 21 Feb 2013 18:36

mfm4aa wrote:My suggestion:


It just needs some tildas - see below.

Code: Select all

@echo off
:loop
if not "%~1"=="" start /w "" "CompiledBinary.EXE" "%~1"
shift
if not "%~1"=="" goto :loop

mfm4aa
Posts: 70
Joined: 13 Feb 2013 14:02
Location: Europe

Re: Batch file help

#4 Post by mfm4aa » 21 Feb 2013 18:51

Thanks!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch file help

#5 Post by foxidrive » 21 Feb 2013 19:13

Another method is this:


Code: Select all

@echo off
for %%a in (%*) do (
"CompiledBinary.EXE" "%%~a"
)

rampatt
Posts: 2
Joined: 21 Feb 2013 17:41

Re: Batch file help

#6 Post by rampatt » 21 Feb 2013 19:22

Thanks very much for the help, worked great.

Fighter8787
Posts: 2
Joined: 25 Feb 2013 19:18

Re: Batch file help

#7 Post by Fighter8787 » 25 Feb 2013 19:23

I have a file that im doing and it calls for this code

Code: Select all

FOR /F "tokens=1-6 delims=," %%G IN (bin/dir/saves/1.txt) DO (
set /a house=%%G
set /a weapon=%%H
set /a damage=%%I
set /a range=%%J
set /a defense=%%K
set /a money=%%L
)
:test
if %house% equ 1 DO (
set %house% equ school
if %house% equ 2 DO (
set %house% equ Gas Station
if %house% equ 3 DO (
set %house% equ Market
if %house% equ 4 DO (
set %house% equ House

but it doesn't work please help. I was wondering if you can change a varaible within a if statement with that varible (if %x% equ 1 DO (set /a x=2)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch file help

#8 Post by foxidrive » 26 Feb 2013 01:41

Try this:

Code: Select all

FOR /F "tokens=1-6 delims=," %%G IN (bin/dir/saves/1.txt) DO (
set house=%%G
set weapon=%%H
set damage=%%I
set range=%%J
set defense=%%K
set money=%%L
)
:test
if %house% equ 1  (set house=school)
if %house% equ 2  (set house=Gas Station)
if %house% equ 3  (set house=Market)
if %house% equ 4  (set house=House)

Fighter8787
Posts: 2
Joined: 25 Feb 2013 19:18

Re: Batch file help

#9 Post by Fighter8787 » 26 Feb 2013 05:12

That you so much! it worked just fine!

Post Reply