[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
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
Medium Priority
?
1,798 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
11 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 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 31

Expert Comment

by:hnasr
ID: 24138661
:) but you need to replace WriteLine file file with WriteLine file objFile
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 67

Expert Comment

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

Expert Comment

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

Assisted Solution

by:t0t0
t0t0 earned 500 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 46

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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

649 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