Results 1 to 20 of 125

Thread: Combine recursive listing with excluded code

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    So basically in “Excludes_7” workbook, there are several problems:

    1. The parent folder displays correctly for files, but does not display correctly for subfolders. For example,

    path (column 1): C:\test\subfolder 1\file 1.txt
    parent folder (column 2): C:\test\subfolder 1

    which is correct

    For subfolders,

    path (column 1): C:\test\subfolder 1
    parent folder (column 2): C:\test\subfolder 1

    which is not correct because subfolder 1 resides inside the C:\test folder. it should say, parent folder (column 2): C:\test

    The parent folder and the path cannot be the same it just doesn't make sense

    2. using the "\\?\ " notation does not display correctly for both column 1 (FILE/FOLDER PATH) and column 2 (PARENT FOLDER)

    (post 28)
    Agree, but since the functionality was required in multiple places, I opted to simplify the lines where it was used by putting the IIF() in the function
    You are correct in the sense that removing the brackets from 2 columns was necessary but, in doing so, column 2 had the wrong parent folder path (see #1 above). Therefore, this code needs to be adjusted:

    Private Function RemovePrefix(s As String) As String
        RemovePrefix = IIf(Left(s, 4) = "\\?\", Right(s, Len(s) - 4), s)
    End Function
    to firstly, remove longer folder path prefix from both columns and secondly, shorten the parent folder path as #1 above.

    I have made a code that shortens what was written in my code

    wsOut.Cells(rowOut, colParent).Value = Right(Left(.path, Len(.path) - Len(.Name) - 1), Len(Left(.path, Len(.path) - Len(.Name) - 1)) - 4)
    to several other ways as shown in the attachment. If it's not shown correctly, then I am uploading my workbook to show those formulas using excel's built-in functions
    Attached Images Attached Images
    Attached Files Attached Files

Posting Permissions

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