How to? Find a specific file in subfolders

Oct 18, 2009
The folder setup I have is this:

\THR\Downloads\2017\06 Jun 2017\01 {current month}
\THR\Downloads\2017\06 Jul 2017\01 {future month}

A file zcs_20170603.txt is moved to the appropriate day folder.
It might be automatically copied to \THR, depending on a variety of factors.

If not, it has to be manually copied to \THR.

The main program then renames the copy, which ultimately gets deleted.

What I would like to do is have the main program look for the original without using a detailed "walk the tree" program so if the user moves the file rather than copying it the main program won't proceed.

It seems there should be an easy way to do that with ffind /s /f {something} >NUL basically saying "Look in subfolders of \Downloads\ until you find or don't find %source_file." I tried \Downloads\*\ but that doesn't work.


Scott Mintz
May 20, 2008
Solon, OH, USA
If you use Everything Search it happens *really* fast.
Everything %source_file

If there's only 1 file you could do something like:
do f in /p everything %source_file (echo File %f was moved! & quit)
Oct 18, 2009
Everything won't work. Both the target file and the .btm file are on network drives.

Also, there will be a copy of the zcs in the folder that contains the .btm, so the search can't include %_cwd. (I didn't realize until after I'd done quite a bit of coding that all data files should have been put folders different from the code folders.)

Speed isn't a major concern. Although \Downloads\ can have 800 subfolders, it would rarely have more than 40 files, and most of those would have a .bak extension, and the target file would be near the top of the tree.
May 20, 2008
Syracuse, NY, USA
I don't know about your syntax for FFIND. FFIND works here, used in various ways on a network drive.
Oct 18, 2009
I'm assuming ffind can work with the proper syntax but I haven't been able to figure it out.

The ffind examples aren't relevant. The last one says "search for wdump.btm in a specific folder". The other ones say "search for wdump.btm in the current folder and any subfolders.

I need "search subfolders of a different folder."

The problem in my case is that ffind /s \Downloads\*\zcs_x.txt seems to only search all folders one level below \Downloads.
On the other hand, ffind /s \Downloads{space}\zcs_x.txt searches for \Downloads
Oct 18, 2009
I just checked the syntax for ffind /s and it says

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.

If you specify a number following the /S, FFIND will limit the subdirectory recursion to the number specified. For example, if you have a directory tree "\a\b\c\d\e", /S2 will only go to the "a", "b", and "c" directories.

If you specify a + followed by a number after the /S, FFIND will not search for files until it gets to that depth in the subdirectory tree. For example, if you have a directory tree \a\b\c\d\e, /S+2 will not find anything in \a or \a\b.

It looks like it will be necessary to write a subroutine that switches to \Downloads, runs ffind /s+2, and switches back to \THR.

I'm going to put a suggestion to add to ffind the ability to set a full path with subfolders.
Oct 18, 2009
The examples using /a:d find folders and they are looking at subfolders of the current working directory. What I would be trying to do is from a command line in C:\dell search for ABC.txt somewhere in a subfolder of D:\MyFiles\2017\

The Help indicates /s with ffind can only search subfolders of the current folder.

Incidentally, I tried using dir instead and it turns out dir works the same way.

As I mentioned, it looks like I'll have to write a routine that switches to \Downloads, runs ffind and then returns to the original directory. The program I use assigns the original directory path to a variable, so that's not a big deal.
May 20, 2008
Syracuse, NY, USA
If you give it a path, that's where it starts looking, not in the CWD.
What I would be trying to do is from a command line in C:\dell search for ABC.txt somewhere in a subfolder of D:\MyFiles\2017\
This seems to be what you mean.

And note: G:\uty\ (and below) is the only place it looked.
Oct 18, 2009
I tried a variation and it worked!


[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

I'll put a follow-up in the Suggestions thread to mention this in the Help.
Similar threads
Thread starter Title Forum Replies Date
J ffind does not find files Support 4
Alpengreis List command: text truncated in find box (german) Support 9
R FIND command error Support 9
vefatica Find Files/Text dialog: does it work? Support 0
T FFind - can we display n number of lines after the find? Support 2
Patulus TCHistoryLog: TCC: (Sys) The system cannot find the path specified Support 15
D unzip fails to find valid license Support 3
R Find in screen buffer - find next behavior Support 0
thedave Problem chaining piped FIND commands in BTM Support 7
D CD doesn't always find everything Support 8
B Fixed FFIND doesn't find last character in file without CR/LF at EOF Support 1
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
vefatica FFIND /S, find directory with specified name? Support 7
D Why doesn't ffind find directory? Support 3
nikbackm How to? Find duplicate lines in text file Support 0
P OK, I can't find how to do this, but I know you wizards will... Support 5
noahcoad WAD cmd.exe under tcc doesn't find apps Support 4
S How to? Find installer downloaded by "option /u"? Support 11
M How to? Find out the total allocated size of a directory tree... Support 7
G Find files but ignore file extension in search Support 2
S CDD Doesn't Find Directory? Support 3
L File association: System cannot find the associated program Support 30
R How to use ffind to find older files? Support 9
Charles Dye Edit / Find dialog Support 0
J Find Files - changing folder Support 1
BobK Error from START cmd, "cannot find the file" Support 16
D ACTIVATE doesn't find windows Support 7
R A problem using find in list when word wrap? Support 2
nikbackm Find out when a process has stopped Support 5
J Find failure dialog box failure Support 0
J Problem with Find dialog Support 3
J Problem with %var:find=replace% syntax Support 5
S LIST and F for find Support 4
M TCC cannot find the path specified Support 4
M TCC Can't find WScript.exe where it says it is Support 0
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
R How to? Dir specific file search patterns with spaces in the pathnames? Support 6
p.f.moore How to? User specific TCSTART (etc) files Support 15
C Registry keys? (not JP specific) Support 0
R specific functions for number conversion Support 2
O Make command history tab-specific Support 2
gschizas pdir crashes horribly in one specific folder Support 5
nikbackm TCC with specific @inifile for new tabs Support 3
S Version-specific icons Support 1
J History file load hangs if file has complete garbage in it... Support 1
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
thorntonpg file explorer - short cut keys Support 1
JohnQSmith New online help file wrong logo Support 7
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
samintz How to? swap endianness in a binary file Support 12

Similar threads