Page 1 of 1

How Can I use a list in a file as variables in a batch?

Posted: 11 Oct 2006 10:42
by quantuml
Hello Dos Guru's
I have a list in a txt file. i want to use each line as a different variable.
i do not mind using only the first line in the file than deleting that line thus the next loop will use the first line again?

i am trying to run a gpg script on only files with the gpg extension.
i ported the directory with a clean list of files to process into a filelist.txt using the :

dir *.gpg /b > filelist.txt

but i now can't figure out how to put these files into variables to use in my batch.

i want to run another batch file on each file...


also there will never be more than 9.

Thanks All!

Posted: 12 Oct 2006 23:47
by DosItHelp
quantuml,

You might want to use a loop like this:

Code: Select all

for /f "tokens=*" %%f in (filelist.txt) do (
    echo.Now processing %%f
    call OtherBatch.bat %%f
)


You could do the same without the intermediate filelist.txt:

Code: Select all

for %%f in (*.gpg) do call OtherBatch.bat %%f


DOS IT HELP? :wink:

It worked Great but now how can i use only the first one

Posted: 24 Oct 2006 12:45
by quantuml
Thanks
The syntax worked great

But now i want to use only the first file it finds.

i have to make it run every 15 minutes on each file it finds.

any suggestions?

Quantuml

Posted: 25 Oct 2006 23:13
by DosItHelp
quantuml,

Do you want to run like this:
file 1, wait 15 minutes, file 2, wait 15 minutes, ..., file N, wait 15 minutes, file 1, wait 15 minutes, file 2, ...

or like this:
file 1, file 2, ..., file N, wait 15 minutes, file 1, file 2, ..., file N, wait 15 minutes, file 1, file 2, ..., file N, wait 15 minutes, ...

:?: :)

Well Lets See

Posted: 01 Nov 2006 16:10
by quantuml
More like
file 1.... (in my script i will delete the file that i just ran the batch on)...

so technically 15 min goes by and i do the same batch on the new file 1

my problem is that the file name changes every time and there might be multiple files that show up. but i do know the extension.

quantuml

Posted: 02 Nov 2006 00:37
by DosItHelp
quantuml,

If you can describe in words how the file can be identified then I can help you with the script, i.e.:
Does the filename always start with the same characters?
Or is it always (guaranteed) the newest file in the directory?
Or something else?

:?:

Ok here is what i need

Posted: 14 Nov 2006 11:19
by quantuml
Hey DosItHelp

Sorry for the deley i thought i had it working but i guess i need the gurus help.

ok i get a series of files everyday in a folder:
ussually formated like this
sdtrigger.todays_date.batchfilenumber.835.pgp

so i ussually only look for the {sdtrigger.*.*.835.pgp} becasue the date and the batch file are always different.

i also get files that are named like this:
SD_FAX.todaysdate.batchnumber.txt.pgp

i want to check to see if there is a file with the "sdtrigger" in the name. if there is i want to process that file.
The process is all setup to go. I would just pass that file name to process batch file.

sometimes there might be more than one file with "sdtrigger" in it. (this happens when there are multiple dates to send.)

also i can't process "sdtrigger" files back to back. i need to wait at least 15 min between processes.

Thanks for the thought.

Quantuml