Re: "FFIND" Exit Codes?
- From: "Steve Fabian" <ESFabian@xxxxxxxxxxx>
- Date: Fri, 28 Mar 2008 09:36:46 -0400
Richard Bonner wrote:
| Richard Bonner (ak621@xxxxxxxxxxxxxx) wrote:
|| 4DOS 7.61
|
|| I wish to have FFIND look for files witn the "Archive" attribute
|| and to issue exit code `0' if it finds any, `1', if it does not.
|
|| Richard Bonner
|
| *** Sorry to be a pain, but I still cannot get this to work. The
| relevant batch file section is:
|
| FFIND /A:+A *.*
| IF ERRORLEVEL 1 GOTO NO-NEW-FILES
| IF ERRORLEVEL 0 GOTO BACKUP
|
| The errorlevel `0' is always the result. )-: I tried various
| error-level testing suggestions given in this thread but the result
| was always the same. Theoretically, if I clear all "Archive"
| attributes in that directory, should not the exit code be `1' ?
|
| Could someone provide the syntax to check the FFIND exit codes as
| above?
FFIND is an internal command. The internal commands which duplicate some
CMD.EXE / COMMAND.COM feature often do return an ERRORLEVEL. However, it is
quite possible that FFIND never sets the errorlevel.
Try testing the exit code designed for internal commands, _?. It may give
you the information you desire. However, often the only information from the
exit code itself is whether or not the command execution ran into trouble,
and you need to capture the command output itself.
BTW, if you are using FFIND just to determine whether or not any files with
attribute A are present in a single directory, you can use the @FILES[]
function:
if %@files[*.*,A] gt 0 goto HAVE_NEW
If you need to know about a whole directory tree, you can use the DIR
command, with option /U2. You may need to pipe it to TAIL to strip
everything but the last line, and you can use the @EXECSTR function to put
the result into a variable.
Somethins like this may work (UNTESTED):
set new=%@word[" ",4,%@execstr[(dir/s/a:a-d/u2/k | tail /n2 )]]
Note the use of a command group as the parameter to @EXECSTR - it is often
critical.
--
HTH, Steve
.
- References:
- "FFIND" Exit Codes?
- From: Richard Bonner
- Re: "FFIND" Exit Codes?
- From: Richard Bonner
- "FFIND" Exit Codes?
- Prev by Date: Re: "FFIND" Exit Codes?
- Previous by thread: Re: "FFIND" Exit Codes?
- Next by thread: Re: ANSI key reassignments under 4NT and/or XP
- Index(es):
Relevant Pages
|