Why no time in TIME.TXT :- echo %time% > TIME.TXT > NUL
Posted: 17 Jul 2013 03:12
Why does NUL capture the text I intend for TIME.TXT ?
I only seem to get the result I want if I use parenthesis, i.e.
I wasted an hour or two before I tried the parenthesis, and I would like to FULLY understand :-
Why I need the parenthesis ;
Any convenient alternatives ;
Any further "gotchas" that I might stumble across
Reason I stumbled into this problem :-
I was echoing a messages to create various single line files in the current directory.
When the file name was short then all was well.
When the file name was long then there was an error message that with typical Microsoft Stupidity stated :-
"The system cannot find the path specified."
CMD.EXE was STANDING on the path that it was using - it did not have to go and find it
So naturally I redirected the error message to NUL.
UNFORTUNATELY EVEN IF the file name was short and the file could have been created,
then the message intended for the file was redirected to NUL instead.
N.B. The purpose of the exercise was to start with a single folder on a long path about 250 characters long,
and build in that folder a series of files with name of increasing length until reaching the Windows limit of 260 characters including the terminating NUL.
Incidentally, I had forgotten the correct term for "brackets" so I looked up
http://www.dostips.com/DtCodeSnippets.p ... ndGrouping
Parentesis is the word I found above - which earns a red squiggle from my spelling checker, and Google takes me to foreign sites such as Spanish, and suggests
Parenthesis
Regards
Alan
I only seem to get the result I want if I use parenthesis, i.e.
Code: Select all
( echo %time% > TIME.TXT ) > NUL
I wasted an hour or two before I tried the parenthesis, and I would like to FULLY understand :-
Why I need the parenthesis ;
Any convenient alternatives ;
Any further "gotchas" that I might stumble across
Reason I stumbled into this problem :-
I was echoing a messages to create various single line files in the current directory.
When the file name was short then all was well.
When the file name was long then there was an error message that with typical Microsoft Stupidity stated :-
"The system cannot find the path specified."
CMD.EXE was STANDING on the path that it was using - it did not have to go and find it
So naturally I redirected the error message to NUL.
UNFORTUNATELY EVEN IF the file name was short and the file could have been created,
then the message intended for the file was redirected to NUL instead.
N.B. The purpose of the exercise was to start with a single folder on a long path about 250 characters long,
and build in that folder a series of files with name of increasing length until reaching the Windows limit of 260 characters including the terminating NUL.
Incidentally, I had forgotten the correct term for "brackets" so I looked up
http://www.dostips.com/DtCodeSnippets.p ... ndGrouping
Parentesis is the word I found above - which earns a red squiggle from my spelling checker, and Google takes me to foreign sites such as Spanish, and suggests
Parenthesis
Regards
Alan