Results 1 to 6 of 6
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    list all files in a directory

    Hey guys,

    I have a network folder full of our product photos. New photos automatically get dropped in there from our manufacturers FTP site. Our IT guys set that up. I need a script or something that will list all the files in that directory and append them into a table in Access.

    Is this possible?

    Currently I run a few commands in cmd and import the file that gets exported from those commands. I need this to be smoother so our higher-ups can update their product catalog with the push of a button.

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    Try -
    Code:
    Sub ShowFiles(FolderName As String)
        Dim File As Variant
        File = Dir(FolderName & "\*")
        Do While Len(File) > 0
            Debug.Print File
            File = Dir
        Loop
    End Sub

  3. #3
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Nice! Worked great. Whats the best way to get that into a table? Recordset add new?

  4. #4
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Also, What exactly is the "File = Dir" line doing?

    I tried to reverse engineer it by removing it and just endlessly prints the name of the first file. So obviously it fixes that problem, but how?

    Thanks!

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    file = dir is just another way of saying go to the next file.

    You can also use filesystemobject commands to do this function. Here's a link to that method:

    http://blogs.technet.com/b/heyscript...ubfolders.aspx

    Either way, once you get the file names you can create a SQL statement and add records to your table if they are new (this would either involve checking to see if you already have a record of the file name or just appending to the table and relying on a unique key to reject the file if the file name/date is the same)

  6. #6
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Ah gotcha. Seems easy enough. I appreciate the help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 01-17-2014, 09:51 AM
  2. Replies: 1
    Last Post: 11-07-2013, 11:15 AM
  3. List of all users from active directory
    By bignate in forum Programming
    Replies: 3
    Last Post: 10-11-2013, 05:53 AM
  4. Replies: 22
    Last Post: 01-28-2013, 02:55 PM
  5. Replies: 6
    Last Post: 06-15-2011, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums