Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: DOS - how to create list of directories without a particular file extn

22 May 2013   #1
undecided

7 64
 
 
DOS - how to create list of directories without a particular file extn

hi,

I'm hoping someone can help me perfect a script/batch file etc that will list my folders that do NOT have a particular file extension in it, currently I've been using something similar to the below which would create a list of all directories on the X drive containing jpg files but what I really want is a list of all the folders where I forgot to add the jpg for instance, having to go through the list and comparing to the full folder list to look for differences is too time consuming and often leads to some being missed:

X:\>dir x:\*.jpg /w/o/s > \jpglist.txt


For example, using the above .jpg extension as an example imagine I had:

X:\2009pictures\holiday.jpg
X:\2010stuff\work.jpg
X:\2011work\reminder.txt
X:\2012pictures\holidaysnap.jpg
X:\2013\todo.doc

I'd like an output text file that says:

X:\2011work
X:\2013

Since these are the folders that do not contain any jpg files.


Really hope someone could help with this, would save me loads of time. I saw an old thread where someone was asking about a similarish type of subject ages ago and got some helpful replies so really hopeful a kind person on here can come to my rescue!

DOS - list files in folders without path


My System SpecsSystem Spec
.
22 May 2013   #2
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Code:
 
dir  /b   /s   x:\|find   /v   /i    ".jpg"
Replace x: with actual drive letter
My System SpecsSystem Spec
22 May 2013   #3
undecided

7 64
 
 

Quote   Quote: Originally Posted by Kaktussoft View Post
Code:
 
dir  /b   /s   x:\|find   /v   /i    ".jpg"
Replace x: with actual drive letter
hi, thanks for that although that seems to list all files and folders that aren't a jpg so I get hundreds of results for all the other files the drive contains (eg .txt .doc), it also lists all the folders on the drive even if they do contain .jpg files so using my above example it shows the X:\2009pictures folder for instance even though it has a jpg inside.
My System SpecsSystem Spec
.

22 May 2013   #4
Ztruker

Windows 10 Pro X64
 
 

This will show you only the directories a specific file type is found in, for example *.zip

dir \*.zip /n /s | find "Directory of"
My System SpecsSystem Spec
26 May 2013   #5
undecided

7 64
 
 

Quote   Quote: Originally Posted by Ztruker View Post
This will show you only the directories a specific file type is found in, for example *.zip

dir \*.zip /n /s | find "Directory of"

thanks, I'll make a note of that, could come in useful although what I'm really after is the exact opposite of that - ie list directories a file type is not in.

Is there a way of listing all directories and listing all directories that have a file in it and then doing a compare and showing the differences, this would give me the list I need.

I was hoping for a DOS command but if it could only be done with vbscript or similar I could live with that, I'd rather keep to stuff that works with standard windows components rather than having to install extra stuff on any PC I used it from but I'd take anything that worked at the moment.
My System SpecsSystem Spec
26 May 2013   #6
Layback Bear

Windows 7 Pro. 64/SP-1
 
 

I'm no expert but did find this. Could this be what you are looking for. Use at your own risk.

DOS - how to create list of directories without a particular file extn-cmd-help-5-26.png


My System SpecsSystem Spec
30 May 2013   #7
undecided

7 64
 
 

Quote   Quote: Originally Posted by Layback Bear View Post
I'm no expert but did find this. Could this be what you are looking for. Use at your own risk.

Attachment 269811
sorry for the delay replying everything got a bit hectic for a few days. that FC command looked promising but I can't seem to get it to show the differences. It just displays the contents of each text file one after the other. For example I created a set of folders as a test and only folder2 and folder3 had jpg files inside, I then did the following:

dir c:\test\*.jpg /n /s | find "Directory of" > c:\in1.txt
(lists folders containing jpg files and outputs to in1.txt)

dir c:\test\*.* /n /s | find "Directory of" > c:\in2.txt
(lists all folders and outputs to in2.txt)

The FC attempt just got the below output, was hoping only differences would be shown, maybe I'm entering it incorrectly?:

FC c:\in1.txt c:\in2.txt
Comparing files C:\in1.txt and C:\IN2.TXT
***** C:\in1.txt
Directory of c:\test\folder2
Directory of c:\test\folder3
***** C:\IN2.TXT
Directory of c:\test
Directory of c:\test\folder1
Directory of c:\test\folder2
Directory of c:\test\folder3
*****


Anyone got any idea what's wrong or have other suggestions?
My System SpecsSystem Spec
31 May 2013   #8
Ztruker

Windows 10 Pro X64
 
 

It's the way FC works. Now diff.exe from the Unix Tools for Win32 does exactly what you want.

I did the following:

dir d:\*.jpg /s /n | find "Directory of" > in1.txt
dir d:\*.* /s /n | find "Directory of" > in2.txt

diff in1.txt in2.txt -y > out.txt & notepad out.txt

That generated a side-by-side output that looks like this:

DOS - how to create list of directories without a particular file extn-diffoutput.jpg

Without any parameter it outputs just the differences, but it puts a offset before each group that I haven't found a way to get rid of yet, looks like this:

> Directory of d:\bootwiz
> Directory of d:\Canon
1a50,61
> Directory of d:\Canon\CameraWindow
> Directory of d:\Canon\CameraWindow\CameraWindowDC
> Directory of d:\Canon\CameraWindow\CameraWindowDC\en
> Directory of d:\Canon\CameraWindow\CameraWindowDVC
> Directory of d:\Canon\CameraWindow\CameraWindowDVC6
> Directory of d:\Canon\CameraWindow\CameraWindowLauncher
> Directory of d:\Canon\CameraWindow\MyCamera
> Directory of d:\Canon\CameraWindow\MyCameraDC
> Directory of d:\Canon\CameraWindow\MyCameraFiles
> Directory of d:\Canon\CameraWindow\MyCameraFiles\DefaultSettings121
> Directory of d:\Canon\CameraWindow\MyCameraFiles\DefaultSettings121\OP_WAV
> Directory of d:\Canon\CameraWindow\MyCameraFiles\DefaultSettings121\RL_WAV
2a63,66
> Directory of d:\Canon\CameraWindow\MyCameraFiles\DefaultSettings121\SS_WAV
> Directory of d:\Canon\CameraWindow\MyCameraFiles\DefaultSettings121\TM_WAV
> Directory of d:\Canon\CameraWindow\MyCameraFiles\OP_WAV


My System SpecsSystem Spec
Reply

 DOS - how to create list of directories without a particular file extn




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
WLM 2011 -how do I create a new Contact list
Just moved to Windows 7 from XP and struggling with Windows Live Mail (amongst other things!). Very basic question but I can't find how to add a new Contact list.
Browsers & Mail
File Explorer crashing (constantly), mostly in directories with images
Hi, I've used this forum many years to find advice, now I'm stuck and need to ask a question (hopefully in the right section): My Window File Explorer is constantly crashing (say at least 10 times a day!). This happens mostly when I open file directories which contain image files, some...
General Discussion
error when installing usig answer file to move user directories.
I am trying to use this example file I found on microsoft's site: <?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend"> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64"...
General Discussion
XP32 > Win7x64 Migrate Settings Data: Chrome+Extn, Outlook+iTunes+App?
XP32 > Win7x64 Migrate Settings Data: Chrome+Extn, Outlook+iTunes+App? How do I migrate these SETTINGS DATA etc so that on the new OS after Application Installation and APP SETTINGS / DATA migration its exactly as before. Especially the following Applications & their Data: OUTLOOK +...
General Discussion
How can I create a list of folders in WORD without retyping them all?
I have many folders with names of clients and would occasionally like to print a list but without retyping them I can't seem to do that. I also have photos that I would like a physical list of but again without retyping them all. Any ideas?
General Discussion
Create Taskbar Pinned Items Into an Expandable List
Hi all, I am starting to have a lot of pinned items on my taskbar. Is there a way to add some into a list I can expand from the taskbar. Here is what I have at work on my XP. Something similiar would be useful! http://i52.tinypic.com/t842te.jpg Thanks Hornet
General Discussion


Our Sites

Site Links

About Us

Find 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 19:03.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App