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


  1. Posts : 4
    7 64
       #1

    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 Computer


  2. Posts : 10,796
    Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
       #2

    Code:
     
    dir  /b   /s   x:\|find   /v   /i    ".jpg"
    Replace x: with actual drive letter
      My Computer


  3. Posts : 4
    7 64
    Thread Starter
       #3

    Kaktussoft said:
    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 Computer


  4. Posts : 6,285
    Windows 10 Pro X64
       #4

    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 Computer


  5. Posts : 4
    7 64
    Thread Starter
       #5

    Ztruker said:
    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 Computer


  6. Posts : 25,847
    Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
       #6

    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 Computer


  7. Posts : 4
    7 64
    Thread Starter
       #7

    Layback Bear said:
    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
    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 Computer


  8. Posts : 6,285
    Windows 10 Pro X64
       #8

    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 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 20:04.
Find Us