Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Oct 2002
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Turning a folder's content into data. (2000)

    Does any one know of a way to easily take a directory and enter the file names in it as data in a database.

    to be more specific. i work in a photographic studio and we have hundreds of photos which are all backed up on cd so we need to be able to search all the contents of the cds fo a clients photos. If you can think of a way to keep thumbnails of them as well, that would be even better. The process must be automated so that employees can easily do it. thanks

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Turning a folder's content into data. (2000)

    Try the following code behind a button:

    Dim dbs as Database, rs as Recordset
    Set dbs = CurrentDB
    set rs = dbs.OpenRecordset("Yourtablename")
    Dim Match as string
    Match = Dir("c:yourdirectoryname*.txt")
    Do While Len(Match) > 0 then
    rs.AddNew
    rs!Filename = Match
    rs.Update
    Match = Dir()
    Loop
    Set rs = Nothing
    Set dbs = Nothing

    HTH
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    nb. I have not run this code to see if it works, but you should get the idea from this.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Turning a folder's content into data. (2000)

    The "old-fashioned" VB way to get all files in a folder is to use the Dir function, for example:

    Dim strPath As String
    Dim strFile As String
    ' specify folder
    strPath = "L:PicFolder"
    ' find first .jpg file in folder
    strFile = Dir(strPath & "*.jpg")
    ' loop through all .jpg files in folder
    Do While strFile <> ""
    ' insert code to process strFile, for example:
    MsgBox strPath & strFile
    ' move to next file
    strFile = Dir
    Loop

    Storing (thumbnails of) photos in a database is not a good idea; it will cause the database size to increase inordinately.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Turning a folder's content into data. (2000)

    Remember to set a reference (in Tools/References...) to the Microsoft DAO ... Object Library if you want to use this.
    Also, to avoid confusion with ADO objects, it's best to name DAO explicitly in your declarations:

    Dim dbs As DAO.Database, rs As DAO.Recordset

  5. #5
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Turning a folder's content into data. (2000)

    Good point, thanks Hans. I guess using A97 too much has made me overlook this.
    Pat <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •