[windows] need help with making a script

Come up with a useful post-processing script? Share it here!
Post Reply
Assmonkey
Newbie
Newbie
Posts: 8
Joined: July 30th, 2009, 4:04 pm

[windows] need help with making a script

Post by Assmonkey »

I'm sure this can be done in 15 seconds by those who know how...

I'm looking for a batch/cmd file that will run another program/command for every filename in the release/download directory (%1 if I'm not mistaken). The command to be run doesn't support wildcards so it needs to be fed each and every filename.
Would also be great if the script waits for the command to end before proceeding to feeding it the next filename.

Thanks in advance! :)
User avatar
TeraLove
Newbie
Newbie
Posts: 18
Joined: June 1st, 2008, 9:07 pm

Re: [windows] need help with making a script

Post by TeraLove »

Just out of curiosity, what is this mystery program that you want to run for each file? :P

Also, what kind of self-insulting username is that?
Last edited by TeraLove on July 30th, 2009, 9:51 pm, edited 1 time in total.
Assmonkey
Newbie
Newbie
Posts: 8
Joined: July 30th, 2009, 4:04 pm

Re: [windows] need help with making a script

Post by Assmonkey »

TeraLove wrote: Just out of curiosity, what is this mystery program that you want to run for each file? :P

Also, what kind of self-insulting username is that?
It's actually an SFV-checker of sorts but not.

You don't like my nick, haha? My girlfriend gave it to me, hahaha. ;D
User avatar
TeraLove
Newbie
Newbie
Posts: 18
Joined: June 1st, 2008, 9:07 pm

Re: [windows] need help with making a script

Post by TeraLove »

Assmonkey wrote:It's actually an SFV-checker of sorts but not.
Wow that's a very clear description. Thank you. Anyhow, what do I care.

Assmonkey wrote:You don't like my nick, haha? My girlfriend gave it to me, hahaha. ;D
You might like to see http://www.urbandictionary.com/define.p ... =assmonkey for the meanings associated with your nick. Maybe then you'll understand. Makes me wonder why a girl would give her boyfriend such a nickname.

Maybe someone can help with your technical concern.
doubledrat
Release Testers
Release Testers
Posts: 180
Joined: February 20th, 2008, 3:16 pm

Re: [windows] need help with making a script

Post by doubledrat »

I know teralove will tell me off for this as it's not generic ;) but this should do what you want

Code: Select all

set dirname=%1
set dirname=%dirname:"=%
set name=%3
set name=%name:"=%
set nbID=%4
set DLTYPE=%5

for /R "%dirname%" %%f in (*.iso) do call :doit "%%f"

GOTO :EOF

:doit
REM the file you want is now in %1 and already has quotes around it
DIR %1
GOTO :EOF
this will work on any .iso.  if you want all files you can use just * otherwise *.whatever
just substitute the DIR for the command you want to run
Last edited by doubledrat on July 31st, 2009, 4:56 am, edited 1 time in total.
Assmonkey
Newbie
Newbie
Posts: 8
Joined: July 30th, 2009, 4:04 pm

Re: [windows] need help with making a script

Post by Assmonkey »

Hehe, seems I managed to do it myself after all. No idea whose is the better solution though. :)
Here's mine:

Code: Select all

FOR /F "usebackq"  %%i IN (`dir /B %1`) DO mycmd.exe="%1\%%i"
doubledrat
Release Testers
Release Testers
Posts: 180
Joined: February 20th, 2008, 3:16 pm

Re: [windows] need help with making a script

Post by doubledrat »

yours is fine as long as you never want to do more than 1 command and your files are not in subdirectories
JoeyJoeJo
Newbie
Newbie
Posts: 20
Joined: August 11th, 2009, 9:37 am

Re: [windows] need help with making a script

Post by JoeyJoeJo »

doubledrat wrote: yours is fine as long as you never want to do more than 1 command and your files are not in subdirectories
you could add a /S to the dir as long as you get all the tokens as one with tokens=1* and delims={somecharacterthatwon'tappearinfilenames} in the options.

Code: Select all

FOR /F "usebackq tokens=1* delims=*" %%i IN (`dir /B /S %1`) DO mycmd.exe="%1\%%i"
Post Reply