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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
quantuml
Posts: 4
Joined: 11 Oct 2006 10:33

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

#1 Post by quantuml » 11 Oct 2006 10:42

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!

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#2 Post by DosItHelp » 12 Oct 2006 23:47

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:

quantuml
Posts: 4
Joined: 11 Oct 2006 10:33

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

#3 Post by quantuml » 24 Oct 2006 12:45

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

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#4 Post by DosItHelp » 25 Oct 2006 23:13

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, ...

:?: :)

quantuml
Posts: 4
Joined: 11 Oct 2006 10:33

Well Lets See

#5 Post by quantuml » 01 Nov 2006 16:10

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

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#6 Post by DosItHelp » 02 Nov 2006 00:37

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?

:?:

quantuml
Posts: 4
Joined: 11 Oct 2006 10:33

Ok here is what i need

#7 Post by quantuml » 14 Nov 2006 11:19

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

Post Reply