Gustav Brock
gustav at cactus.dk
Tue May 20 11:13:51 CDT 2003
Hi Roz > Does anyone have a code snippet for pulling file search results into Access? > What I want is to pull the filename, path & size of all files of a given > type on a particular drive, including those in subfolders, into a table. I > need to do it *fast*!!! Maybe this can help you. /gustav --- From: "Gary Kjos" <garykjos at hotmail.com> To: accessd at mtgroup.com Date: Mon, 13 Nov 2000 21:52:26 CST Hi Mark, I do something similarly to load a table of JPG files. I first scan to find all the directories using the vbDirectory parameter of the dir command, then save the directory name in a tblDirectoriesToScan table. Then I read that table and look for all the .jpg files in each directory. Here is a snipit of the first routine that get's the directories.... Set rst = dbs.OpenRecordset("tblDirToScan", dbOpenTable) rst.Index = "DirToScanPath" ' Returns filename with specified extension. If more than one *.ini ' file exists, the first file found is returned. MyFile = Dir(Me!txtInputPath & "\*.*", vbDirectory) ' MyFile = Dir(strCurrentPath & "\*.jpg") If MyFile <> "" Then Do Until MyFile = "" With rst ' Specify record to find. rst.Seek "=", Me!txtInputPath & "\" & MyFile If rst.NoMatch Then .AddNew ' Add new record. !DirToScanPath = Me!txtInputPath & "\" & MyFile ' Add data. .Update ' Save changes. lngAddCount = lngAddCount + 1 Else lngSkipDup = lngSkipDup + 1 End If End With MyFile = Dir Loop End If rst.close And here is the guts of the code to get the filenames; Set rst = dbs.OpenRecordset("tblPicture", dbOpenTable) rst.Index = "Picture" ' Returns filename with specified extension. If more than one *.ini ' file exists, the first file found is returned. Do Until rsdir.EOF strCurrentPath = rsdir!DirToScanPath Me!txtCurrentDir = strCurrentPath Me.Repaint MyFile = Dir(strCurrentPath & "\*.jpg") If MyFile <> "" Then Do Until MyFile = "" With rst ' Specify record to find. rst.Seek "=", strCurrentPath & "\" & MyFile If rst.NoMatch Then .AddNew ' Add new record. !Picture = strCurrentPath & "\" & MyFile ' Add data. !FileName = MyFile !FilePath = strCurrentPath !FileSize = FileLen(strCurrentPath & "\" & MyFile) ' Returns file length (bytes). !FileDate = FileDateTime(strCurrentPath & "\" & MyFile) .Update ' Save changes. lngAddCount = lngAddCount + 1 Else lngSkipDup = lngSkipDup + 1 End If End With MyFile = Dir Loop End If rsdir.MoveNext Loop rst.close Good luck, hope this helps. Gary garykjos at hotmail.com >From: "Mark A Matte" <markamatte at hotmail.com> >Reply-To: accessd at mtgroup.com >To: accessd at mtgroup.com >Subject: [accessd]Find Files... >Date: Mon, 13 Nov 2000 21:29:51 GMT > >Hello All, > >In Access97 I am trying to pull a list of .mdb files with their name,size, >location, and last modified on a 'Shared Drive'...I am using the 'Dir' >function in a loop...but I can't get it to look into each folder. I am >looking for the same information you would get if you select >"MicrosoftAccessDatabase" on the advanced tab in the "Find Files/Folders" >on >the start menu, but I need it in a printable version. I'm not even sure I >am heading in the right direction...it seems there would be an easy way to >get what I am looking for...but...I am missing it. Any Ideas? > >Thanks Again, >Mark A. Matte