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

chrisdukes

New member
Local time
1:53 PM
Messages
4
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 My Computer

At a glance

Windows 7 64bit Enterprise SP1
Computer type
PC/Desktop
OS
Windows 7 64bit Enterprise SP1
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 My Computer

At a glance

Windows 10 Pro x64 EN-GB1.6 GHz Intel Core i7-720QM Processor6 GBATI Mobility Radeon HD 5850 Graphics
Computer type
Laptop
Computer Manufacturer/Model Number
HP ENVY 17-1150eg
OS
Windows 10 Pro x64 EN-GB
CPU
1.6 GHz Intel Core i7-720QM Processor
Memory
6 GB
Graphics Card(s)
ATI Mobility Radeon HD 5850 Graphics
Sound Card
Beats sound system with integrated subwoofer
Monitor(s) Displays
17" laptop display, 22" LED and 32" Full HD TV through HDMI
Screen Resolution
1600*900 (1), 1920*1080 (2&3)
Hard Drives
Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
External: 2TB for backups, 3TB USB3 network drive for media
Cooling
As Envy runs a bit warm, I have it on a Cooler Master pad
Keyboard
Logitech diNovo Media Desktop Laser (bluetooth)
Mouse
Logitech Performance Mouse MX
Internet Speed
50/10 Mbps VDSL
Antivirus
Windows Defender 4.3.9431.0
Browser
Maxthon 3.5.2., IE11
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 My Computer

At a glance

Windows 7 64bit Enterprise SP1
Computer type
PC/Desktop
OS
Windows 7 64bit Enterprise SP1
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:

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 [B][COLOR="Blue"][hl]/r[/hl][/COLOR][/B] %%x in (*) do (
if not exist %%x\*.xmpb (
echo %%x >>X:\FolderList.txt
)
)

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:
[B][COLOR="Blue"][hl]@echo off[/hl][/COLOR][/B]
for /d /r %%x in (*) do (
if not exist %%x\*.xmpb (
echo %%x >>X:\FolderList.txt
)
)

Thanks again for your help and patience!
You are welcome :).

Kari
 
Last edited:

My Computer My Computer

At a glance

Windows 10 Pro x64 EN-GB1.6 GHz Intel Core i7-720QM Processor6 GBATI Mobility Radeon HD 5850 Graphics
Computer type
Laptop
Computer Manufacturer/Model Number
HP ENVY 17-1150eg
OS
Windows 10 Pro x64 EN-GB
CPU
1.6 GHz Intel Core i7-720QM Processor
Memory
6 GB
Graphics Card(s)
ATI Mobility Radeon HD 5850 Graphics
Sound Card
Beats sound system with integrated subwoofer
Monitor(s) Displays
17" laptop display, 22" LED and 32" Full HD TV through HDMI
Screen Resolution
1600*900 (1), 1920*1080 (2&3)
Hard Drives
Internal: 2 x 500 GB SATA Hard Disk Drive 7200 rpm
External: 2TB for backups, 3TB USB3 network drive for media
Cooling
As Envy runs a bit warm, I have it on a Cooler Master pad
Keyboard
Logitech diNovo Media Desktop Laser (bluetooth)
Mouse
Logitech Performance Mouse MX
Internet Speed
50/10 Mbps VDSL
Antivirus
Windows Defender 4.3.9431.0
Browser
Maxthon 3.5.2., IE11
Back
Top