Solved

how to find all .jpg files in my computer using FileSystemObject, the output is to a txt file

Posted on 2009-04-14
11
1,692 Views
Last Modified: 2013-11-09
How can I write a script to list all .jpg files in my computer by using FileSystemObject. The result should be put in a text file.
0
Comment
Question by:vbsnoob
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 24137960
This should do it..
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objOut = objFSO.CreateTextFile ("C:\JPGReport.txt")

Set objFolder = objFSO.GetFolder("C:\")
 

Set colFiles = objFolder.Files

For Each objFile in colFiles

  If LCase(Right(objFile.Name, 3)) = "jpg" Then objOut.WriteLine file

Next
 

ScanFolders objFSO.GetFolder("C:\")

objOut.Close

wscript.quit
 

Sub ScanFolders(strFolder)

    For Each strSubFld in strFolder.SubFolders

        Set objFolder = objFSO.GetFolder(strSubFld.Path)

        Set colFiles = objFolder.Files

        For Each objFile in colFiles

          If LCase(Right(objFile.Name, 3)) = "jpg" Then objOut.WriteLine file

        Next

        ScanFolders strFolder

    Next

End Sub

Open in new window

0
 

Author Comment

by:vbsnoob
ID: 24138157
thank you very much for ur speedy help!
0
 
LVL 30

Expert Comment

by:hnasr
ID: 24138661
:) but you need to replace WriteLine file file with WriteLine file objFile
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24138677
oops... :^)
0
 
LVL 30

Expert Comment

by:hnasr
ID: 24138691
:) but you need to replace WriteLine file with WriteLine objFile
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 16

Assisted Solution

by:t0t0
t0t0 earned 125 total points
ID: 24139544
Why not simply use a DOS command as in:

   dir /a-d /b /s c:\*.jpg >jpgfiles.txt

The results can be viewed by opening the JPGFILES.TXT in notepad etc...
0
 
LVL 45

Expert Comment

by:aikimark
ID: 24150000
I think the t0t0 suggestion is the best.
0
 
LVL 16

Expert Comment

by:t0t0
ID: 24153769
aikimark

Thank you.
0
 
LVL 6

Expert Comment

by:Justin_W_Chandler
ID: 24167765
OBVIOUSLY, he has a reason for doing it in VB. I wouldn't be surprised if he's got an assignment for school that he's trying to get some help with.
0
 
LVL 16

Expert Comment

by:t0t0
ID: 25850454
i'm good wih that!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The viewer will learn how to count occurrences of each item in an array.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now