Folders with just ONE FILE

General discussion related to "Everything".
Post Reply
pachame13
Posts: 4
Joined: Mon Mar 04, 2019 2:55 pm

Folders with just ONE FILE

Post 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.
vanisk
Posts: 152
Joined: Sat Oct 27, 2018 11:33 am

Re: Folders with just ONE FILE

Post 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)
pachame13
Posts: 4
Joined: Mon Mar 04, 2019 2:55 pm

Re: Folders with just ONE FILE

Post 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.
therube
Posts: 4977
Joined: Thu Sep 03, 2009 6:48 pm

Re: Folders with just ONE FILE

Post by therube »

Could you explain more fully what you're wanting.
vanisk
Posts: 152
Joined: Sat Oct 27, 2018 11:33 am

Re: Folders with just ONE FILE

Post 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
ovg
Posts: 294
Joined: Thu Oct 27, 2016 7:19 pm

Re: Folders with just ONE FILE

Post by ovg »

2vanisk

For me

Code: Select all

child:temp.txt childcount:1 childfilecount:1
working like a charm!
pachame13
Posts: 4
Joined: Mon Mar 04, 2019 2:55 pm

Re: Folders with just ONE FILE

Post 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.
vanisk
Posts: 152
Joined: Sat Oct 27, 2018 11:33 am

Re: Folders with just ONE FILE

Post 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
2019-03-05 06_12_22-Everything.jpg (18.18 KiB) Viewed 6376 times

(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)
void
Developer
Posts: 16735
Joined: Fri Oct 16, 2009 11:31 pm

Re: Folders with just ONE FILE

Post 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.
pachame13
Posts: 4
Joined: Mon Mar 04, 2019 2:55 pm

Re: Folders with just ONE FILE

Post 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.
Post Reply