• Sorted directory listing (97 / 2002)

    Author
    Topic
    #400986

    I wrote an application that uses the Dir() function to find all the JPG files in a folder and does some processing on them. It does its job, but now I find that it’s important to process the files in alphabetic order. Help for Dir() states that Dir() returns the files in no particular order, and its up to the programmer to sort the list manually using an array. I think I can do this, but it seems a bit clunky, and was wondering what other people do when confronted with the same requirement. Comments?

    PS. I searched Google etc for a class module that would do this task, but came up empty. Does anybody have some code that can be dropped into an existing application that I could use? Thanks.

    Viewing 5 reply threads
    Author
    Replies
    • #786390

      Why don’t you search on google to find SORT.

      An alternative is to append these filename entries to a table, then use a query or SQL code to read thru the table in filename order.

    • #786391

      Why don’t you search on google to find SORT.

      An alternative is to append these filename entries to a table, then use a query or SQL code to read thru the table in filename order.

    • #786394

      This newsgroup post demonstrates how to use FileSystemObject from the Scripting library together with a disconnected ADO recordset to sort the directory listing.

      More ideas in the thread starting with post 343243.

    • #786395

      This newsgroup post demonstrates how to use FileSystemObject from the Scripting library together with a disconnected ADO recordset to sort the directory listing.

      More ideas in the thread starting with post 343243.

    • #786578

      If interested, see attached sample database (A2K format). Form frmListFiles has a listbox that lists files with specified file spec, from specified folder, in alphabetical order. A callback function (LoadFileList) is used to populate list; the file list is generated using DIR function (see GetFileList function); the file list is sorted using a standard-issue QuickSort (see QuickSortArray sub). These functions performed efficiently in testing, even with large numbers of files in a directory. When form opens, default file spec is “C:*.*”, this can be modified to suit other purposes.

      HTH

    • #786579

      If interested, see attached sample database (A2K format). Form frmListFiles has a listbox that lists files with specified file spec, from specified folder, in alphabetical order. A callback function (LoadFileList) is used to populate list; the file list is generated using DIR function (see GetFileList function); the file list is sorted using a standard-issue QuickSort (see QuickSortArray sub). These functions performed efficiently in testing, even with large numbers of files in a directory. When form opens, default file spec is “C:*.*”, this can be modified to suit other purposes.

      HTH

    Viewing 5 reply threads
    Reply To: Sorted directory listing (97 / 2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: