search for folders that contain 3 or more files with the same extension

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
rockberto
Junior Member
Junior Member
Posts: 7
Joined: 2024-07-16, 08:42 UTC

search for folders that contain 3 or more files with the same extension

Post by *rockberto »

Hi to everyone.
There's a way in Total Commander to search folders that contain 3 (or more) files with the same extension?
for example I want to search for all folders that have at least 3 .flac files
thanx in advance
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: search for folders that contain 3 or more files with the same extension

Post by *Stefan2 »

rockberto wrote: 2024-07-17, 21:58 UTC search folders that contain 3 (or more) files with the same extension?
for example I want to search for all folders that have at least 3 .flac files

Not with TC alone.

I took a look and came up with this:

Open a PowerShell console in the "main"-folder.


Try something like this:

Instead, better see below the post by NotNull
gci -dir -rec | ?{$_.GetFiles('*.flac').Count -gt 2} | select -exp FullName | Set-Content C:\Temp\_myLoadlist.txt
my code deleted

$FOLDERS = Get-ChildItem d:\directory | ?{$_.PSISContainer}
or
$FOLDERS = GCI -Recurse | ?{$_.PSISContainer} # the current folder


Next paste in:

Code: Select all

$OUT=''
ForEach ($FLD in $FOLDERS){
	Set-Location $FLD.FullName
	"`n`nDEBUG FOLDER: $($FLD.FullName) "
	GCI -File | Group -Property Extension |
		Select-Object Name, Count |
			ForEach{if ($_.Name -eq '.flac' -AND $_.Count -gt 2){"YES"; $OUT+=$($FLD.FullName)+"`r`n"}}
}
"`n`nRESULT:`n$OUT"


EXPORT the result to a text file:
$OUT | Set-Content C:\Temp\_myLoadlist.txt
[/color]

Next use TC's LOADLIST to load that list of folders into TC.
For more details about this LOADLIST see:
viewtopic.php?p=457717#p457717   (Search folders that contain txt files that contains a specific word)



 
User avatar
petermad
Power Member
Power Member
Posts: 16001
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: search for folders that contain 3 or more files with the same extension

Post by *petermad »

2rockberto
As I just learned today, you can use the FileMask plugin http://www.mgpsoft.net/Downloads/FileMask.zip for such a task.

You will have to add the extension you want to search for to the [DirMask] section of the FileMask.ini file in the plugin folder - like this:

Code: Select all

[DirMask]
Flac=*.flac
You can then use the Plugins tab in TC's Find Files dialog:
Plugin: filemask
Property: DirMask
OP: >=
Value: 3 [Flac]

Leave the "Search for:" field blank in the General tab.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
NotNull
Senior Member
Senior Member
Posts: 298
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: search for folders that contain 3 or more files with the same extension

Post by *NotNull »

Do you have Everything 1.5 installed and configured to work with Total Commander?

In that case, search for

Code: Select all

ed:  child:*.flac  child-occurrence-count:>2
It will list all folders below the active folder that contain 3 or more .flac files.

(can't test it atm, but should work)



Stefan2 wrote: 2024-07-21, 10:22 UTC[..]PowerShell[..]
Alternative:

Code: Select all

gci -Directory -Recurse | Where { $_.GetFiles('*.flac').Count -gt 2 } | select FullName
Fla$her
Power Member
Power Member
Posts: 2982
Joined: 2020-01-18, 04:03 UTC

Re: search for folders that contain 3 or more files with the same extension

Post by *Fla$her »

NotNull wrote: 2024-07-21, 19:53 UTC child-occurrence-count
I found it only here. Why doesn't the author update the options in the help?
Overquoting is evil! 👎
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: search for folders that contain 3 or more files with the same extension

Post by *Stefan2 »

NotNull wrote: 2024-07-21, 19:53 UTC Alternative:

Code: Select all

gci -Directory -Recurse | Where { $_.GetFiles('*.flac').Count -gt 2 } | select FullName
WOW :shock: thanks

That's not an alternative, but the real way of doing this task.



I never noticed that "GetFiles"

Works fine

1)
gci -dir -rec | ?{$_.GetFiles('*.TxT').Count -gt 2} | select -exp FullName | Set-Content C:\Temp\_myLoadlist.txt

2)
use TCs LOADLIST
LOADLIST C:\Temp\_myLoadlist.txt
and then Ctrl+T to double the search result



 
User avatar
white
Power Member
Power Member
Posts: 5747
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: search for folders that contain 3 or more files with the same extension

Post by *white »

Moderator message from: white » 2024-07-22, 22:34 UTC

Moved 7 off-topic posts starting with this post into topic
» ENG: Small talk / Geplauder / Forum Moderation / Spam-Report / Off-Topic
NotNull
Senior Member
Senior Member
Posts: 298
Joined: 2019-11-25, 20:43 UTC
Location: NL

Re: search for folders that contain 3 or more files with the same extension

Post by *NotNull »

Stefan2 wrote: 2024-07-22, 07:35 UTC I never noticed that "GetFiles"
Just sharing .. found out about it a couple of weeks ago, so you're not alone in that ;)
rockberto
Junior Member
Junior Member
Posts: 7
Joined: 2024-07-16, 08:42 UTC

Re: search for folders that contain 3 or more files with the same extension

Post by *rockberto »

sorry for the delay in replying. We have had a busy period and I have not been able to use the computer. In the meantime, thanks for your answers, tomorrow we will be back up and running and I will do all the tests with your suggestions. Thanks!
Post Reply