If you want to find the number of text files within a computer’s folder then you can use the following PowerShell command:-
> $txt=0 > switch -wildcard (Get-ChildItem -Path E:\txt) { *.txt {$txt++}} > "text files: $txt" text files: 5
The above PowerShell command uses the switch statement to loop through all the files within the txt folder which is under the E drive and each time one will be added to the $txt variable if that particular file is a text file. At last, the command displays the number of text files within that folder on the PowerShell command prompt.