1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ffind not setting %_ffind_ vars if /f is used

Discussion in 'Support' started by Rick Reinckens, Jun 25, 2017.

Tags:
  1. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    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.
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,078
    Likes Received:
    30
    Apparently so. And what's the difference between _FFIND_MATCHES and _FFIND_FILES?
    upload_2017-6-25_12-37-53.png
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,078
    Likes Received:
    30
    Never mind that question. _FFIND_MATCHES is the number of text matches.
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,040
    Likes Received:
    84
    FFIND doesn't set the command variables on a /F because there isn't any point in doing that. If FFIND returns 0, then it found a (maximum of 1) match. If FFIND returns <> 0, then it didn't find anything.
     
  5. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    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.
     
  6. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    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.
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,078
    Likes Received:
    30
    As Rex said, you can do it (silently) by checking the variable _? instead of the variable _ffind_files. It's no more work.
    upload_2017-6-25_19-47-20.png
    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.
    upload_2017-6-25_19-53-40.png
     
  8. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    DON'T USE /F, USE /-1

    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!
     
    #8 Rick Reinckens, Jun 25, 2017
    Last edited: Jun 26, 2017

Share This Page