locked
How to Search for files in Windows Developer Preview RRS feed

  • Question

  • How can I search for files larger that a given size, located in various folders, using Command prompt or Windows explorer?

    For example, I would like to find all the files that are larger than 320 bytes, and are located in subfolders, under a folder named "A".


    Thursday, February 2, 2012 7:25 PM

All replies

  • I would like to find all the files that are larger than 320 bytes, and are located in subfolders, under a folder named "A".


    For performance and reliability I would have more hope doing that with PowerShell than either WE or cmd.   Unfortunately, in the W8 DP the PS ISE has had its Help files removed and I don't know off the top of my head what the necessary syntax would be in PS to do this.  FWIW though, I envision it would be a really simple "one-liner"--two stages max--GC | Where-Object with the {} script block being where you would express your "larger than 320 bytes" criterion.

    TTT I was actually thinking of piping to ForEach-Object but found this while trying to get an example of a  -gt  relation  <w>

    http://technet.microsoft.com/en-us/library/ee177028.aspx

     

    HTH

    Robert Aldwinckle
    ---

    Thursday, February 2, 2012 8:30 PM
  • cd into your A directory then:

    get-childitem -R | where-object Length 320 -GE

    Thursday, February 2, 2012 8:54 PM
  • cd into your A directory then:

    get-childitem -R | where-object Length 320 -GE


    Well, that's very good. It would be nice If I could get the total number of the files it returns, though

    Thanks

    Thursday, February 2, 2012 9:41 PM
  • It would be nice If I could get the total number of the files it returns



    At the risk of turning this into a PS tutorial...

    (gci -R | where-object Length -GT 320).count

     

    BTW  this demonstrates the risk of using cryptic shorthand.   It was  Get-ChildItem  (or its alias dir) I was thinking of when I wrote GC but that's Get-Content and trying to use that caused some head-scratching trying to interpret the resulting error messages.   <eg>

    Also, novice PS'er that I am I would only have found this syntax and not realized that just the property could imply the piped object as Ben's example shows to be a shorter alternative.

    (gci -R | where-object {$_.length -GT 320}).count

     

    Robert
    ---

    Thursday, February 2, 2012 10:56 PM
  • At the risk of turning this into a PS tutorial...


    I hardly want it, too...

    My first attempt was to search using Windows Explorer, as there are some fixed file sizes under Search tools. So, I thought that I could use a similar search string in WE's search field.

    BTW, besides wildcards and quotes, what other marks/syntax can I use in WE's search field? Is there an article/tutorial somewhere?

    Thanks for your help

    Friday, February 3, 2012 3:35 PM
  • BTW, besides wildcards and quotes, what other marks/syntax can I use in WE's search field? Is there an article/tutorial somewhere?


    http://sourcedaddy.com/windows-7/advanced-query-syntax.html

    Unfortunately I can't credit the poster who showed us this a while ago since this forum is not well indexed on BING.

    Aha.  Google found what I was remembering

    http://social.msdn.microsoft.com/Forums/sa/windowsdeveloperpreviewgeneral/thread/25d037b6-15cf-4259-9cb7-86a924276d02

    (Google web search for
        inanchor:advanced inanchor:query inanchor:syntax site:msdn.microsoft.com/forums
    )

    So it was  AndyCadley  we have to thank for that reference.

     

    Robert
    ---

    Friday, February 3, 2012 8:20 PM