Search: Can you search for a folder that's missing a filetype?


  1. Posts : 4
    Windows 7 64bit Enterprise SP1
       #1

    Search: Can you search for a folder that's missing a filetype?


    Basically, I want to search for all the folders on my drive that are missing an *.xmpb file. All of the folders should have one, but some of them don't, so I need a list of those folders. What's the syntax? I tried--

    kind:folder NOT *.xmpb

    --but it didn't work. Also, this is on a mapped network drive but that's never interfered with my searches before.

    Thanks for any help, you'll be seeing me.
      My Computer


  2. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #2

    Hi Chris, welcome to the Seven Forums.

    It can't be done with Windows Search. The search you tried (kind:folder NOT *.xmpb) lists all folders where the folder name does not contain string .xmpb.

    However, what you want to achieve is totally doable with a simple batch file:

    1. @echo off
    2. for /d /r %%x in (*) do (
    3. if not exist %%x\*.xmpb (
    4. echo %%x >>X:\FolderList.txt
    5. )
    6. )

    Batch explained:
    • Line 1 > Disable output to console while running the batch
    • Line 2 > Check folders in current location and recursively down the whole folder structure
    • Line 3 > If a folder does not contain a file matching *.xmpb (change to whatever you need) ...
    • Line 4 > ... add the folder name and path to X:\FolderList.txt list (change the drive and text file name to what you want to)
    • Line 5 > Repeat 3. checking the next folder until the whole folder tree has been gone through
    • Line 6 > Quit

    The above example has line numbers to match explanations below it. Here's the same code without line numbers, copy & paste this to a new file in Notepad and save with *.bat extension, naming it as you wish (AnyName.bat):
    Code:
    @echo off
    for /d /r %%x in (*) do (
    if not exist %%x\*.xmpb (
    echo %%x >>X:\FolderList.txt
    )
    )
    Now run the batch in Command Prompt in root of the drive or top of the folder tree which you want to check.

    About FOR loops in batch files: For

    Kari
      My Computer


  3. Posts : 4
    Windows 7 64bit Enterprise SP1
    Thread Starter
       #3

    This is awesome, Kari. Thanks a bunch, it works exactly as you said.

    I have a few questions:
    What's a good site to learn more about making batch files and advanced searching? (I bookmarked MS Technet)
    How would I change line 2 so only the first sub-level of folders is searched? (I'm looking over Technet)
    And, how can I see it process in the command prompt window?

    Thanks again for your help and patience!
      My Computer


  4. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #4

    chrisdukes said:
    What's a good site to learn more about making batch files and advanced searching? (I bookmarked MS Technet)
    This is one of the best batch guides I know:

    Tutorials for Windows Search:


    chrisdukes said:
    How would I change line 2 so only the first sub-level of folders is searched? (I'm looking over Technet)
    The recursive switch /r (highlighted in code sample below) is the one which tells the batch to go through all subfolders down to last level in folder tree. Take it away to only go through first level subfolders:
    Code:
    @echo off
    for /d /r %%x in (*) do (
    if not exist %%x\*.xmpb (
    echo %%x >>X:\FolderList.txt
    )
    )
    chrisdukes said:
    And, how can I see it process in the command prompt window?
    Command echo off turns output to console (Command Prompt) off, the preceding @ sign turns off displaying the echo off command itself. Cut the whole command out (highlighted in below code sample) to see normal command output in console:
    Code:
    @echo off
    for /d /r %%x in (*) do (
    if not exist %%x\*.xmpb (
    echo %%x >>X:\FolderList.txt
    )
    )
    chrisdukes said:
    Thanks again for your help and patience!
    You are welcome :).

    Kari
    Last edited by Kari; 25 Nov 2014 at 16:14. Reason: Typos fixed, at least the worst ones
      My Computer


 

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

© Designer Media Ltd
All times are GMT -5. The time now is 15:37.
Find Us