Re: "FFIND" Exit Codes?



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

.



Relevant Pages

  • Re: "FFIND" Exit Codes?
    ... Steve Fabian wrote: ... || and to issue exit code `0' if it finds any, `1', if it does not. ... | IF ERRORLEVEL 1 GOTO NO-NEW-FILES ... quite possible that FFIND never sets the errorlevel. ...
    (comp.os.msdos.4dos)
  • Re: "FFIND" Exit Codes?
    ... ||| Does anyone know the exit codes for FFIND? ... | IF ERRORLEVEL 1 ECHO NOT FOUND ... echo external exit code was 0 ...
    (comp.os.msdos.4dos)
  • Re: FUNCTION and IF
    ... There is a difference between a function value and an errorlevel. ... It is the EXIT CODE of an internal or external command, ... (internal command exit code). ...
    (comp.os.msdos.4dos)
  • Re: How to set exit code of non-console app?
    ... NOT yet returned an exit code to Windows (even though it has returned ... control to the command prompt, ... behavior does NOT occur if executing within a command script."). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Deploy Adobe Acrobat 6.0 using sms 2003
    ... >I tried to install Adobe Acrobat 6.0 using sms 2003 without much luck. ... > "This is what I put in my sms package command line: ... A failure exit code of 1624 was returned. ...
    (microsoft.public.sms.swdist)