Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

DOS SCRIPT

Oct 6, 2011 9:30AM PDT

Back in the real DOS days I was doing simple
batch files as a hobby more than anything else.



Now I want to write a batch file to zip a folder. That much I can do - but I never got to
understanding passing arguments to batches
(just did static ones all the time)
so when I say a '%' in a file I zoned out.

Here is the key line which works


Rem folderzip.bat
Rem ZIPNT.exe -r archive_location source_folder_location

ZIPNT.exe -r "I:\backup\destination.zip" "D:\jobs\Gympie_Rd\Option
B10_Webster Road\*.*"



And its the source_folder_location (but potentially both paths) which I want to
pass to the batch file as an argument from another app where we can issue a
command to the OS shell.



Any help much
appreciated

Discussion is locked

- Collapse -
Answer
Re: parameters
Nov 2, 2011 7:07AM PDT
- Collapse -
Answer
dos script... it has been a while
Nov 2, 2011 8:56AM PDT

For what it's worth, I seem to remember that %0 represents the batch file itself, then %1 through %?? represent parameters in the order passed.

Something like:
run.bat "c:\folder_1\" "c:\folder_2\" would pass the path c:\folder_1\ to your batch file as %1 and path c:\folder_2 as %2.
Does this help?
john3


wiyk