+ Reply to Thread
Results 1 to 4 of 4

find filename in path regardless of number of subfolders

  1. #1
    Registered User
    Join Date
    12-18-2013
    Location
    Best, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    8

    find filename in path regardless of number of subfolders

    Hello good people of the Excel forum!

    I was wondering if you could help me with this problem:

    let's say I have a list of files in column A:

    /folder/subfolder1/subfolder2/subfolder3/file1.txt
    /folder/subfolder1/subfolder2/file2.txt
    /folder/subfolder1/file3.txt
    /folder/file4.txt

    in column B I would like to see just the filenames:

    file1.txt
    file2.txt
    file3.txt
    file4.txt

    How can I achieve this?

    On the internet I found this forumule which looks promising but unfortunately finds the first slash (instead of the last) and prints what's to the right of that slash:

    =RIGHT(C2; LEN(C2) - SEARCH("/";C2))

    there seem to be other solutions to this problem available online, but honestly, I don't fully understand what they are supposed to do and also they don't seem to work...

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: find filename in path regardless of number of subfolders

    This should work nicely:

    =TRIM(RIGHT(SUBSTITUTE(A1,"/",REPT(" ",100)),100))

    This substitutes 100 spaces for each " / " and then pulls the last 100 characters from the right, thereby only grabbing the filename each time. Trim then drops all the extra spaces.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Registered User
    Join Date
    12-18-2013
    Location
    Best, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: find filename in path regardless of number of subfolders

    Hello daffodil11,

    You are awesome.


    Thanks so much!

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: find filename in path regardless of number of subfolders

    Hurray! Glad I could help out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to extract filename from path\filename
    By mpan in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-05-2013, 11:23 PM
  2. Find File with partial filename and get path of folder
    By axisambrosia in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-16-2012, 06:51 AM
  3. Replies: 3
    Last Post: 07-09-2012, 03:09 PM
  4. Workbooks.open to search in a certain path and its subfolders
    By Macko07 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-23-2012, 08:12 AM
  5. Find filename, path, document size, filename length and path length?
    By Laneyboggs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2010, 08:01 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1