How do you search c disk for all the files with the extension txt

Page 1 of 2 12 LastLast

  1. Posts : 5
    Windows 10 Home
       #1

    How do you search c disk for all the files with the extension txt


    Hello,

    So, I'm looking for quite a detailed search in CMD or RUN (not sure if they are the same), which is searching disk C for all the documents with extension txt also having 150kb. I've got Windows 10 Home if that helps?

    Many thanks
    Mihaela
      My Computer


  2. Posts : 6,971
    windows 10
       #2

    Welcome to the forum. Open cmd prompt type
    Cd\
    Dir *.txt /s
      My Computer


  3. Posts : 4,224
    Windows 10
       #3

    What Samuria says is quite correct and workable. It's also possible to use a third-party search tool -- I'm a devoted user of Voidtools (Search) Everything tool, which is faster and more capable than built-in Windows search -- to search for *.txt, either on a single drive or some combination of drives.
    HTH,
    --Ed--
      My Computers


  4. Posts : 5
    Windows 10 Home
    Thread Starter
       #4

    Thank you Samuria for the reply and for the welcome ! :)
    Trying to type that in but i get different messages all the time like the syntax it's not correct, like it's not recognized as an internal or external command? Can i kindly ask how exactly should look like?

    Many thanks
    Mihaela
      My Computer


  5. Posts : 5
    Windows 10 Home
    Thread Starter
       #5

    Thank you EdTittel for the reply! I've noted the other program you are using, but unfortunately for this one i will have to use CMD
      My Computer


  6. Posts : 4,551
    Windows 11 Pro 64-bit
       #6

    You can't use Dir or any other commands to list only text files with file size 150kb, you will need to create a batch script to accomplish this task.

    Execute below command to list all text files stored at C: partition and sort the list of text files starting from smallest text files.


    Code:
    Dir  /s  /o:s   C:\*.txt  | more
      My Computer


  7. Posts : 25,066
    10 Home x64 (21H2) (10 Pro on 2nd pc)
       #7

    FreeBooter said:
    You can't use Dir or any other commands to list only text files with file size 150kb...
    Not in a Command prompt, but you can in Powershell. This finds all *.txt files in the current directory or below in the size range 150kb to 300kb.

    Code:
    Get-ChildItem *.txt -recurse | where  {($_.Length) -gt 150KB} | where {($_.Length) -lt 300KB}

    Well, actually you can run Powershell commands in a Command prompt, like this...

    Code:
    powershell  "Get-ChildItem *.txt -recurse | where  {($_.Length) -gt 150KB} | where {($_.Length) -lt 300KB}"

    If you search recursively from the root of the C:\ drive you'll want to supress error messages when trying to access folders you don't have permission for. To do that you should add -erroraction 'silentlycontinue' to your powershell command.

    Code:
    Get-ChildItem C:\*.txt -recurse -erroraction 'silentlycontinue' | where  {($_.Length) -gt 150KB} | where {($_.Length) -lt 300KB}
    Last edited by Bree; 28 Dec 2017 at 17:19.
      My Computers


  8. Posts : 13,957
    Windows 10 Pro X64 21H1 19043.1503
       #8

    Maybe if you explain exactly what you are trying to do we can be of more help. Why do you need to use CMD prompt or RUN box?

    Bree, when I run the last example you posted, this is what I get:

    Code:
    PS C:\Windows\System32\WindowsPowerShell\v1.0>         Get-ChildItem C:\*.txt -recurse -erroraction 'silentlycontinue' |
     where  {($_.Length) -gt 150KB} | where {($_.Length) -lt 300KB}
    
    
        Directory:
        C:\Users\ztruk\Documents\AppData\Local\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\AC\AppCache\ADAOO2L2\101
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----       10/30/2015   5:07 AM         272448 C__Windows_SystemApps_Microsoft.Windows.Cortana_cw5n1h2txyewy_cache_De
                                                     sktop_2[1].txt
    
    
        Directory: C:\Users\ztruk\Documents\AppData\Local\Packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\LocalState\Devic
        eSearchCache
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----        2/15/2016   9:33 AM         226246 SettingsCache.txt
    
    
        Directory: C:\Users\ztruk\Documents\AppData\Roaming\Roxio
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    -a----        4/23/2015  11:23 PM         183934 PlasmaLog.txt
    Get-ChildItem : Access is denied
    At line:1 char:9
    +         Get-ChildItem C:\*.txt -recurse -erroraction 'silentlycontinu ...
    +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Get-ChildItem], UnauthorizedAccessException
        + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetChildItemCommand
    
    
    
    PS C:\Windows\System32\WindowsPowerShell\v1.0>
    PS C:\Windows\System32\WindowsPowerShell\v1.0>         Last edited by Bree; 1 Hour Ago at 06:19 PM.
    At line:1 char:32
    +         Last edited by Bree; 1 Hour Ago at 06:19 PM.
    +                                ~~~~
    Unexpected token 'Hour' in expression or statement.
        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : UnexpectedToken
    
    PS C:\Windows\System32\WindowsPowerShell\v1.0>
    PS C:\Windows\System32\WindowsPowerShell\v1.0>       My ComputersSystem Spec
    My : The term 'My' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:7
    +       My ComputersSystem Spec
    +       ~~
        + CategoryInfo          : ObjectNotFound: (My:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    
    PS C:\Windows\System32\WindowsPowerShell\v1.0>     Quote Quote   Multi-Quote This Message
    Quote : The term 'Quote' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:5
    +     Quote Quote   Multi-Quote This Message
    +     ~~~~~
        + CategoryInfo          : ObjectNotFound: (Quote:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    Why am I getting the errors, other than Access Denied, those I understand.
      My Computers


  9. Posts : 25,066
    10 Home x64 (21H2) (10 Pro on 2nd pc)
       #9

    Ztruker said:
    Bree, when I run the last example you posted, this is what I get:

    Code:
     .....
    PS C:\Windows\System32\WindowsPowerShell\v1.0>
    PS C:\Windows\System32\WindowsPowerShell\v1.0>         Last edited by Bree; 1 Hour Ago at 06:19 PM.
    At line:1 char:32
    +         Last edited by Bree; 1 Hour Ago at 06:19 PM.
    +                                ~~~~
    Unexpected token 'Hour' in expression or statement.
    ...
    PS C:\Windows\System32\WindowsPowerShell\v1.0>       My ComputersSystem Spec
    My : The term 'My' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    ...
    ...
    PS C:\Windows\System32\WindowsPowerShell\v1.0>     Quote Quote   Multi-Quote This Message
    Quote : The term 'Quote' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    ...
    Why am I getting the errors, other than Access Denied, those I understand.
    Finger trouble - you appear to have accidentally pasted more than just the command (looks like the rest of the post got copied too). :)
      My Computers


  10. Posts : 13,957
    Windows 10 Pro X64 21H1 19043.1503
       #10

    Must have, sorry. Did it again and ran in the Powershell ISE and it worked great.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 14:03.
Find Us




Windows 10 Forums