4NT Shell Tips and Pitfalls

From miki
Revision as of 09:44, 19 January 2009 by Mip (talk | contribs) (4NT Shell moved to 4NT Shell Tips and Pitfalls: Let's uniformize a bit the title)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Frequent Mistakes

REM ===============================================================================================================================
REM 4NT BATCH FILES FREQUENT MISTAKES
REM ===============================================================================================================================

goto :EOF& REM to avoid execution of this example file...

REM -------------------------------------------------------------------------------------------------------------------------------

REM WRONG - @attrib match only files that have all attribute listed
echo %@attrib["My File",a]%
REM ... '1' if ONLY Archive bit is set

REM GOOD - Use p as 3rd param to make partial match
echo %@attrib["My File",a,p]%
REM ... '1' if Archive bit is set

REM -------------------------------------------------------------------------------------------------------------------------------

REM WRONG - %1 might contain space, but @attrib requires LFN with space to be surrounded with quote
echo %@attrib[%1,a,]%

REM GOOD - Use "%@full[%1]%" to force quote
echo %@attrib["%@full[%1]%",a,]%

REM -------------------------------------------------------------------------------------------------------------------------------

REM in 4NT, for /r skip SYSTEM / HIDDEN files/directories (in W2K, only HIDDEN files are skipped).
for /r "." %%i in (*.*) do echo %%i

Hints and Tips

REM ===============================================================================================================================
REM 4NT BATCH FILES TIPS AND TRICKS
REM ===============================================================================================================================

goto :EOF& REM to avoid execution of this example file...

REM -------------------------------------------------------------------------------------------------------------------------------

REM To force a batch file to run with 4NT:

if "%@eval[2+2]%" equ "4" goto :4NTSHELL
4NT /c %0 %*
goto :EOF

:4NTSHELL

REM To force a single command to run with 4NT

set FNT=
if "%@eval[2+2]%" neq "4" set FNT=4NT /c
%FNT% *dir /a:a /sfn %*
pause