Results 1 to 8 of 8
  1. #1
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133

    List files recursively AB


    So I have been playing with listing files in a list box from a directory using Allen Browne's List Files Recursively http://allenbrowne.com/ser-59.html it works great and I understand most of it. The thing I'm being nit picky about today is it lists the directory path behind the file names, where in the call function would i specify to leave this out, and what would I have to type?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I tested function and not getting that output. The full path\filename is listed as a single string and column in listbox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    I'm not the best at wording things sometimes haha, I want to get rid of the file path to just show the file names.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Try:

    lst.AddItem Right(varItem, InStrRev(varItem, "\"))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Not sure if I have the code added correctly, it doesn't return errors.. but also doesn't seem to be doing this either.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You could try this:
    Code:
    <snip>
        'Add the files to the folder.
        strFolder = TrailingSlash(strFolder)
        strTemp = Dir(strFolder & strFileSpec)
        Do While strTemp <> vbNullString
          ' colDirList.Add strFolder & strTemp   '<<<<<< strFolder is the path
            colDirList.Add strTemp    '<< change the above line to this
            strTemp = Dir
        Loop
    <snip>
    Realize if there are more than one file name the same in different directories (bIncludeSubfolders is TRUE), you won't know what
    directory they are in......
    Last edited by ssanfu; 09-13-2017 at 04:57 PM.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Sorry, thought that worked but now not sure what I did. So this one definitely worked:

    lst.AddItem Right(varItem, Len(varItem) - InStrRev(varItem, "\"))

    In case the forum drops it, should be a \ in between those quote marks.

    I looked at modifying the FillDir function but decided not to mess with the primary code that iterates folders.
    Last edited by June7; 09-13-2017 at 10:56 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    Forbes's Avatar
    Forbes is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    133
    Quote Originally Posted by ssanfu View Post
    You could try this:
    Code:
    <snip>
        'Add the files to the folder.
        strFolder = TrailingSlash(strFolder)
        strTemp = Dir(strFolder & strFileSpec)
        Do While strTemp <> vbNullString
          ' colDirList.Add strFolder & strTemp   '<<<<<< strFolder is the path
            colDirList.Add strTemp    '<< change the above line to this
            strTemp = Dir
        Loop
    <snip>
    Realize is there are more than one file name the same in different directories (bIncludeSubfolders is TRUE), you won't know what
    directory they are in......
    Thank you so much for all your help guys this ended up solving the problem very easily, June7 I did not try your new method but it will be useful if this doesn't last as expected. Ssanfu, Basically what my program does is use shell commands to rename (ren) a massive list of files to a imported list of file names, so with any luck.. no file names should ever be the same and it's only in one child directory

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

Similar Threads

  1. list files in a directory
    By alfrval in forum Access
    Replies: 2
    Last Post: 02-25-2015, 12:46 PM
  2. list all files in a directory
    By snipe in forum Programming
    Replies: 5
    Last Post: 01-21-2014, 12:18 PM
  3. Replies: 4
    Last Post: 09-20-2013, 03:20 PM
  4. list files recursively and store results in array
    By maxbre in forum Programming
    Replies: 2
    Last Post: 11-10-2011, 01:49 AM
  5. How To View List of Files in Box
    By treyprice in forum Forms
    Replies: 3
    Last Post: 01-14-2010, 03:40 PM

Tags for this Thread

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