11) FOR %%V IN /SOMETHING ... quoting Dirk Treusch to All ... How can a batch file (without 4DOS) determine from which drive it has been started? Example: C:\> a:test.bat Now my batch should be able to find out that it is located on drive A: (not the path - only drive!). Mitch Ames responds: The variable %0 contains the name of the batch file _as_it_was_typed_at_the_command_line. If you call the batch file as A:TEST.BAT, %0 will be "A:TEST.BAT". If you have the directory on your path, and simply type TEST, then %0 will be "TEST". The drive, path and extension will only appear in %0 if you enter them in the command used to call the batch file (either typed at the command line, or called from another batch file). So you _must_ specify the drive as part of the batch filename for this to work. To extract the drive only, use STRINGS, or similar (I don't have a copy, so don't ask me to post it). Alternatively use the undocumented FOR %%V in /SOMETHING command, eg: set drive= for %%v in (/%0) do call test2 %%v echo Calling drive is %drive% where TEST2.BAT is: if not '%drive%'=='' set drive=%1: Disclaimer - I haven't tested this. Debugging is up to you. (You can, of course, fit this into a single recursive batch file - but that's left as an exercise for the student.) FOR %%V IN (/SOMETHING) DO WHATEVER will do WHATEVER twice - the first time with %%V set to the first character in SOMETHING ("S"), the second time with all the remaining characters in SOMETHING ("OMETHING"). If SOMETHING is only a single character, WHATEVER will only be called once, with that character in %%V. If the single character is a wildcard (? or *) that wild card will _not_ be expanded to a set of filenames. (The main purpose of this feature is apparently to allow inclusion of the literal characters "?" and "*" without them being expanded.) This works in DOS 3.30 and 5 - I don't know about other versions. Mitch Ames =============================================================================== 12) LEADING SLASH WITH FOR IN DO LOOP In the FOR statement in the INIT and COUNT routines below the parameters in the () show a leading "/". This seems to separate the first digit of the environmental variable used within the brackets (). Am I correct? Is this documented anywhere? :================= INIT ================= set &=%4&|set n$=%4|set m$=%3|set #=%2|set !=%0 if not '%m$%'=='0' for %%a in (/%m$%z) do if '%%a'=='0' set @=0 %!% :================= COUNT ================ if '%&%'=='&' goto PROCESS for %%a in (/%&%) do set &=%%a Peter Joynson I have read some articles about this in PC Computing & PC Magazine. I don't believe it is documented anywhere but you're right, it strips off the first character of whatever string is passed. I will try to find one of the articles that explains it better if you need it. Robert Hupf Correct. I believe it is not documented (up to DOS 5 anyway) by MS, but I have read from other sources that the leading / will split an item into the first character and everything else. Eg: for %%n in (/hello there) do echo %%n will display "h", "ello" and "there". "There" is not split because it is a separate item, delimited by the space. If used with an item including wildcard (? or *) characters the item will not be expanded to the files which match it, thus allowing inclusion of those characters in the set. Eg: for %%n in (/? /*.bat hello) do echo %%n will display "?", "*", ".bat", "hello". This apparently is the original reason for the feature, but it may also be used recursively to parse a string one character at a time. Mitch Ames ===============================================================================