ffind not setting %_ffind_ vars if /f is used

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Oct 18, 2009
I'm using ffind with /s to search for one file in various subdirs.

If I use /s without /f, when the command completes %_ffind_files is set to 1. If I include /f, %_ffind_files is set to 0 even though there was one match.

It seems this is not a recent bug. I'm seeing the same problem in TCC 13 and TCC 18.
Oct 18, 2009
There is a point in doing it. (By the way, these are network drives, so Everything won't work.)

What I want to do is silently determine whether one particular file exists "somewhere" below \THR\Downloads\ I can accomplish "silently" by having the ffind output>NUL. Then I look at %_ffind_files to determine whether the file was found. If I don't use /F I have to wait for ffind to look through over 700 subfolders, all but 3 of which definitely won't contain files.

There is one folder for the year, 12 subfolders for the months, 1 subfolder in those for each day of the month, and each day subfolder has a \comments subfolder. After a day is processed, its folder is moved elsewhere. So on Jan 1 ffind would have to search 1 + 1 + 12 + 366 + 366 = 746 folders. Since Jan 1 would be near the top of the tree, with /F it stops almost immediately.

(By the way, even with setting /S to only search a specific level, it would still require searching up to 366 "day" folders.)

With /F, there is no way to tell just from looking at %_ffind_files whether ffind found something. %_ffind_files comes back 0 whether ffind found something or not. I would have to write the output of ffind to a temp file, then check whether the temp file has a length greater than 0, then delete the temp file.

For an unrelated issue I already use ffind to check the data file for the "bad" characters ; = < and >. When I found out TCC/LE doesn't set the %_ffind_ variables I had to use the write-to-temp-file-then-check-file-length-then-delete approach. But that workaround shouldn't be necessary with TCC.

Aside from that, the Help doesn't say anything about ffind not setting the %_ffind_ variables if the /F parameter is used. So someone expecting it to work would think their program has a bug elsewhere.
Oct 18, 2009
Incidentally, you might consider adding a /Q parameter, so the %_ffind_ variables will still be set but there won't be any screen output.

In both my "does this file contain bad characters" and "does this file exist somewhere" uses, I don't want anything displayed, I just want to know yes or no.
As Rex said, you can do it (silently) by checking the variable _? instead of the variable _ffind_files. It's no more work.
There's also @FILES[] which might do your job. Like FFIND, it has the unusual feature that path\file means search only path is "/S" is not specified, and means search path and subdirectories if "/S" is specified. @FILES returns the number found.
Oct 18, 2009

That too causes it to stop after 1 match, but %_ffind_files does get set.

So ... the Help should be clarified that %_ffind_ are not set if /F is used but "stop after first match" can be accomplished by using /-1 instead if those are needed.

Thanks for you help everyone!
Last edited: