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

Starting folder for ffind /s

Discussion in 'Suggestions' started by Rick Reinckens, Jun 24, 2017.

  1. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    I'm trying to accomplish the following and ffind /s can't do it because it only searches for subfolders of the current folder. I'm looking for a filename ending with a date, and each day the file will be in a different subfolder 3 levels down from \Downloads.

    %_cwd = F:\THR
    Without changing the current folder, check for the existence of zcs_YYYYMMDD.txt in
    F:\THR\Downloads\{year}\{month}\{day}

    I could extract the date, parse it, convert month # to 06 Jun 2017, but I'd like something simpler.

    When using /s, ffind should have an option to set the starting folder for the search.

    Also, the help says there are options /s+3, -- start searching 3 levels down from %_cwd, and /s2 -- only search two sublevels. Is there a way to combine those two, i.e., "start searching 3 levels down from \Downloads (i.e., the {day} folders) and only search one level" ? If not, combining those is an additional suggestion.
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    Use attributes. And you can start at ".".
    upload_2017-6-24_11-17-59.png
     
  3. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    I addressed this in another thread. It finds folders, not a specified file. Also, it's looking for subfolders of the current working directory. I want to be able to look at subfolders of a different directory. The Help indicates ffind only looks for subfolders of the current working directory.
     
  4. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    Looks to me like it works the way it is. TCC V20.11.46 x64 :
    Code:
    ~\Work> ffind /s \scifi\x.txt
    C:\scifi\cons\Boskone51\reg\x.txt
    C:\scifi\cons\boskone52\reg\x.txt
    C:\scifi\cons\Boskone53\reg\x.txt
    C:\scifi\cons\Heliosphere2017\reg\x.txt
    C:\scifi\cons\Lunacon_2016\reg\x.txt
    C:\scifi\cons\Lunacon_2017\reg\x.txt
    
          6 files
    
     
  5. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    I tried a variation of the discussion in the other thread and it works. I was assuming that because I want a specific file in a subfolder of \Downloads it was necessary to include one or more subfolder wildcards, otherwise ffind would just look for \Downloads\myfile.txt

    In \THR

    [F:\CLIENT DOWNLOADS\THR] ffind /f /s "F:\CLIENT DOWNLOADS\THR\Downloads\zcs_20170622.txt"

    F:\CLIENT DOWNLOADS\THR\Downloads\2017\06 - Jun 2017\24\zcs_20170622.txt

    [F:\CLIENT DOWNLOADS\THR] ffind /f /s "F:\CLIENT DOWNLOADS\THR\Downloads\zcs_20170623.txt"
    0 files

    The on-line help needs to be changed--it is both inaccurate and misleading:

    Part of the current /S Help:

    Display matches from the current directory and all of its subdirectories. By default, FFIND processes only those subdirectories without the Hidden or System attributes. To view hidden or system subdirectories use /A along with /S.

    That seems to say that if you are in folder C:\MyDir\ it won't search subfolders of D:\OtherFolder\ because D:\... is not a subdirectories of "the current directory."

    Related to that, in the test example above the Help is not clear that you don't need something between the target file name (zcs...) and the "check subfolders of" folder. I thought that even with the /s parameter if I specified to search for \THR\Downloads\zcs_20170622.txt it would not search any folders below \Downloads unless I added a \Downloads\*\ or something similar--which doesn't work.
     
    #5 Rick Reinckens, Jun 25, 2017
    Last edited: Jun 25, 2017
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    The help could be changed rather easily.

    In the syntax line, change "file" to "[target_directory\]file". And under "/S" change "current directory" to "target_directory" and maybe include an example.
     
  7. Rick Reinckens

    Joined:
    Oct 18, 2009
    Messages:
    96
    Likes Received:
    4
    Those Help changes won't work. As I ran into, they give the impression that [target_directory\] is the final folder.

    In my working example, I thought that ffind would only look for zcs_20170622.txt in the folder \Downloads\ because it would think I specified the full path. Either that, or it would fail because it would think I was saying "look in subfolders of \zcs_20170622.txt\" and I didn't specify the file to look for in the (non-existent) \zcs_20170622.txt\ subfolder.

    [F:\CLIENT DOWNLOADS\THR] ffind /f /s "F:\CLIENT DOWNLOADS\THR\Downloads\zcs_20170622.txt"

    I don't see how it could be easily explained without an example.

    (There is also a separate issue that if you use the /f switch ffind doesn't set the %_ffind_ variables, so they always return 0 even if a match is found.)
     
  8. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    I've been using FFIND for 25+ years and it has always been quite simple. If the "file" specification does not contain a '\' it names the thing(s) you're looking for and the search happens in the current directory (the root of the search). If it does contain a '\', what's before the '\' names the root of the search and what's after the '\' names what you're looking for. Without "/S" only the root is searched; with "/S" the root and all its subdirectories are searched.
     
  9. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    Nicely stated, Vince.
     
  10. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    Thanks! But it's a little off. A "\" with nothing before it will also specify the root of the search; it has its usual interpretation when the first character in a path, meaning the root of the current drive.
     

Share This Page