Page 1 of 1

Folders with just ONE FILE

Posted: Mon Mar 04, 2019 2:59 pm
by pachame13
I cannot get the syntax right to find folders with JUST ONE FILE.
My ultimate goal is to find folders that contain just one file with a specific file extension (e.g. temp.txt) and NO OTHER files in that folder, so I can delete the folder safely.

Re: Folders with just ONE FILE

Posted: Mon Mar 04, 2019 3:21 pm
by vanisk
Try this

Code: Select all

child:temp.txt childcount:1 childfilecount:1
either childcount or childfilecount on the above will work. I added both just to be sure.


Please correct me, if i'm wrong

Code: Select all

childcount:1
listing folder containing only one item (either file or directory) in it

Code: Select all

childfilecount:1
listing folder containing only one file (may be or may not be directories present along with it)

Re: Folders with just ONE FILE

Posted: Mon Mar 04, 2019 4:24 pm
by pachame13
Thank you for the prompt reply! It does not seem to work, though. It points to the correct folders (temp.txt files in them) but there are other files in those folders.

Re: Folders with just ONE FILE

Posted: Mon Mar 04, 2019 4:53 pm
by therube
Could you explain more fully what you're wanting.

Re: Folders with just ONE FILE

Posted: Mon Mar 04, 2019 4:54 pm
by vanisk
if we put both childcount & childfilecount to 1 in a single query, it limits to only 1 sub-item and it should be file.

Did u try with both childcount & childfilecount in a single query?

child:temp.txt childcount:1 childfilecount:1

Re: Folders with just ONE FILE

Posted: Mon Mar 04, 2019 7:56 pm
by ovg
2vanisk

For me

Code: Select all

child:temp.txt childcount:1 childfilecount:1
working like a charm!

Re: Folders with just ONE FILE

Posted: Mon Mar 04, 2019 11:41 pm
by pachame13
You're right!
Let me explain what wasn´t working. When I write the full filename (temp.txt) it works as intended and is good for me, now.
But, when I tried it with *.txt (file extension txt but any filename) to catch any folder with just one file ending in .txt, regardless of the filename, it didn´t work.

Re: Folders with just ONE FILE

Posted: Tue Mar 05, 2019 12:49 am
by vanisk
pachame13 wrote:
Mon Mar 04, 2019 11:41 pm
You're right!
Let me explain what wasn´t working. When I write the full filename (temp.txt) it works as intended and is good for me, now.
But, when I tried it with *.txt (file extension txt but any filename) to catch any folder with just one file ending in .txt, regardless of the filename, it didn´t work.
Did u happen to have any excluded file extensions or something like that?

I ran the query "child:*.txt childcount:1 childfilecount:1" on my machine and found 361 results, I manually opened all of them ( YES all the 361 :x total madness or OCD or curiosity :?: ), but found 360 folders had only 1 file (of txt extension) and ONLY 1 folder had 7 files (1 .txt file and other 6 .lnk files).

N.B: *.lnk is being excluded in my Everything settings.
2019-03-05 06_12_22-Everything.jpg

(Further, can you please tell us what other file types were included in the result. So that Admins or void could give you a solution)

Re: Folders with just ONE FILE

Posted: Tue Mar 05, 2019 1:05 am
by void
when I tried it with *.txt (file extension txt but any filename) to catch any folder with just one file ending in .txt, regardless of the filename, it didn´t work.
Please make sure you use child:*.txt
*.txt on its own will most likely not match any folders.

Please make sure regex is disabled from the Search menu.

Re: Folders with just ONE FILE

Posted: Wed Mar 06, 2019 2:32 pm
by pachame13
Now it's completely working fine! I did as you suggested.
I cannot tell you how much your prompt and professional help meant to me. Best regards, Alberto.