?
Solved

search all drives for jpg and jpeg files

Posted on 2005-03-06
5
Medium Priority
?
394 Views
Last Modified: 2010-04-17
hello experts, i want a visual basic6 code which searchs all the drives for jpg and jpeg files and put it in mdb file ,
thanks
0
Comment
Question by:xodos
[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
5 Comments
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13472998
Use the file system object to check to see if the file exists.

Here is a URL :

http://www.juicystudio.com/tutorial/asp/files.asp

And I need to go through my PAQ's to give you the other URL that would help you :)
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13473021
Here is my other PAQ :

Instead of having the if statement searching for *.*mp3 make it jpg or jpeg , hopefully that helps you. btw it writes the resultes to a text file. You can alter that to your needs :)
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 2000 total points
ID: 13473101
Here is an example that requires a reference to microsoft scripting runtime and also a reference to Microsoft ActiveX Data Objects Library:


Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "Kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &H103
Const PROCESS_QUERY_INFORMATION = &H400

Private Function ShellWait(PathName, Optional WindowStyle As VbAppWinStyle = vbNormalFocus) As Double
Dim hProcess As Long, RetVal As Long
    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(PathName, WindowStyle))
    Do
        GetExitCodeProcess hProcess, RetVal
        DoEvents: Sleep 100
    Loop While RetVal = STILL_ACTIVE
End Function

End Sub

Private Sub Command1_Click()
Dim fso, drives, isReady
Set fso = CreateObject("Scripting.FileSystemObject")
Dim FileList As String
Set drives = fso.drives

FileList = Environ("Temp") & "\JpegList.dat"

Dim ff As Integer
ff = FreeFile
Open FileList For Output As #ff: Close #ff

For Each Drive In drives
    isReady = Drive.isReady

    If isReady Then
        ShellWait Environ("Comspec") & " /c dir " & Drive.DriveLetter & ":\*.jpg /s /b >> " & FileList, vbHide
        ShellWait Environ("Comspec") & " /c dir " & Drive.DriveLetter & ":\*.jpeg /s /b >> " & FileList, vbHide
    End If
Next

set fso = Nothing

Dim DataBase As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
DataBase = "C:\MyDataBase.mdb"

' open Database Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & DataBase & "'"
cn.CursorLocation = adUseClient
cn.Open

' open recordset
Set rs = New ADODB.Recordset
rs.Open "Select * From MyTableName", cn, adOpenKeyset, adLockOptimistic

ff = FreeFile
Open FileList For Input As #ff
Do Until EOF(ff)
Line Input #ff, Ln

' add new record to Table
rs.AddNew
rs.Fields("YourFieldName").Value = Ln
rs.Update

DoEvents
Loop
Close #ff

' close recordset
rs.Close
Set rs = Nothing

' close connection
cn.Close
Set cn = Nothing

Kill FileList

End Sub

0
 

Author Comment

by:xodos
ID: 13474551
hello vinnyd79 , thanks for the code ,
but i want it to create the file CMyDataBase.mdb automatically ,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

765 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