1.

Solve : Batch File with variable Filenames?

Answer»

Hi!

I'm new in the batch file things and i need help...
What I want to do is to create a batch file that LOADS files into a specific software...

there is a command that we use to load a file such as:

"load -a "
basically the server and application are known and constant... what is changing is the filename.
I have a folder that contains over 200 files and I want to load them all...
so how can I create a batch file that will load each file of the 200 ?

Please help
thank you in advance!forgot to tell you i'm running windows 2000 SP4....I'm not sure that load is a valid command. That said, you would have to script your application not the command processor.

On the other hand, if load is valid then something like this might work:

CODE: [Select]
for /f %%a in ('dir /b path\*.ext') do (load <server> -a <application> %%a)


Fixup path\*.ext and fill in and with real world values.

Thank you very much for your time and effort!!
It worked perfectly fine!



Hey!

I have another question...

After the above loop is DONE, no files should remain in the directory because the load command actually deletes the files after a successfull load... So I need to check if the directory is empty. If not empty I need an error message to be displayed....

Thank you for your support! hope to hear from you soon....Why do you insist on punishing yourself with these CRYPTIC batch files?

[sigh]

Code: [Select]
@echo off
for /f "tokens=1-3" %%a in ('dir yourdirgoeshere ^| find /i "file(s)"') do (
if %%c==0 echo Directory is Empty
if not %%c==0 echo Directory NOT Empty
)


Fill in yourdirgoeshere and you should be good to go.

Hope this helps.



Discussion

No Comment Found