Whenever anyone says batch scripting is hard, I agree with them. And I've been doing DOS since 3.1 (and CP/M and even older mainframe/mini operating systems before that), along with many other types and flavors of command-line / batch scripting. I'm one of those weirdos who actually wrote batch scripts that did things like calculation and complex string manipulation before MS added these capabilities.

While many command line interface things are much easier to do than most people think, there are many tips, tricks, and gotchas that command line weenies have picked up through the years and just take for granted. (You mean you didn't KNOW the easiest way to parse each line in a text file is with the FOR command? You didn't KNOW that you can use the SET command as a simple calculator for numeric strings?)

What makes batch scripting especially difficult is the downright weird things MS has seen fit to do with their syntax in order to maintain some semblance of backward compatibility. Just look at something as basic as environment variables. What does the following yield when run from a batch file?

@echo off
set ONE=abcd
set TWO=efgh
echo %ONE%TWO
echo %ONE%TWO%
echo %ONE%%TWO
echo %ONE%%TWO%
rem Demonstrate the difference in argument variable handling
echo %0%TWO
echo %0%TWO%
echo %0%%TWO
echo %0%%TWO%
rem Most non-DOS scripters might think this should work in both cases.
if %ONE% NEQ %TWO% echo They are different
set TWO=
if %ONE% NEQ %TWO% echo They are different

Oh, and don't forget that
set ONE=abcd
and set ONE = abcd
may be handled differently in different versions of DOS/CMD.

Now add the complexity and weirdness of the SET command to manipulate these variables and you can see how anyone can get confused.

Now for a bonus question -- what does this command do when executed from the root directory of an NTFS partition (NT/2K)? For all my ranting, it is a good demonstration of some of the power of the CMD interface. [Big Grin]

for /f "delims=*" %i in ('dir /b/ad/s') do cacls "%i" >> cacls.txt

Cheers,

New Mexico Mark

P.S. BrianTX... The previous command is a good example of just how complex it could be to try to do a decent BAT2KIX program. I seriously doubt this command could be reproduced with less than 50 KiXtart statements, even if we ignored the complexity of trying to parse it in the first place.

[ 24 April 2002, 17:33: Message edited by: New Mexico Mark ]