Page 1 of 1

[windows] need help with making a script

Posted: July 30th, 2009, 4:09 pm
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! :)

Re: [windows] need help with making a script

Posted: July 30th, 2009, 9:49 pm
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?

Re: [windows] need help with making a script

Posted: July 31st, 2009, 12:48 am
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

Re: [windows] need help with making a script

Posted: July 31st, 2009, 1:06 am
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.

Re: [windows] need help with making a script

Posted: July 31st, 2009, 4:53 am
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

Re: [windows] need help with making a script

Posted: July 31st, 2009, 6:34 am
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"

Re: [windows] need help with making a script

Posted: July 31st, 2009, 8:29 am
by doubledrat
yours is fine as long as you never want to do more than 1 command and your files are not in subdirectories

Re: [windows] need help with making a script

Posted: August 23rd, 2009, 5:31 am
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"