Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Filename extract from Filepath Text String

Hi

I am trying to find a simple formulaic way of extracting the filename from a
filepath. I have looked at the Text related functions in Excel and they all
appear inapplicable due to the variable nature of filepaths i.e. the number
of sub-folders and the variation in naming of all elements. As an example
see below:

C:\Documents and Settings\Local Settings\My Local
Data\Graduation\campusmap.pdf

From the above I would want to extract just: campusmap.pdf

I have tried to locate the position of the final \ and use that as the key
to extract the filename but I am struggling to define this despite reading
all related posts on the subject. Any help very much appreciated.

Best regards
Dave
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Filename extract from Filepath Text String

On Thu, 20 Dec 2007 07:07:01 -0800, DaveyC
wrote:

Hi

I am trying to find a simple formulaic way of extracting the filename from a
filepath. I have looked at the Text related functions in Excel and they all
appear inapplicable due to the variable nature of filepaths i.e. the number
of sub-folders and the variation in naming of all elements. As an example
see below:

C:\Documents and Settings\Local Settings\My Local
Data\Graduation\campusmap.pdf

From the above I would want to extract just: campusmap.pdf

I have tried to locate the position of the final \ and use that as the key
to extract the filename but I am struggling to define this despite reading
all related posts on the subject. Any help very much appreciated.

Best regards
Dave



with your full path in A1:

=MID(A1,1+FIND(CHAR(1),SUBSTITUTE(A1,"\",CHAR(1),
LEN(A1)-LEN(SUBSTITUTE(A1,"\","")))),255)

will return everything after the last "\"

--ron
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Filename extract from Filepath Text String

With your path in a1 you could try

=MID(SUBSTITUTE(A1,"\","^",LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))),FIND("^",SUBSTITUTE(A1 ,"\","^",LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))))+1,256)

Mike

"DaveyC" wrote:

Hi

I am trying to find a simple formulaic way of extracting the filename from a
filepath. I have looked at the Text related functions in Excel and they all
appear inapplicable due to the variable nature of filepaths i.e. the number
of sub-folders and the variation in naming of all elements. As an example
see below:

C:\Documents and Settings\Local Settings\My Local
Data\Graduation\campusmap.pdf

From the above I would want to extract just: campusmap.pdf

I have tried to locate the position of the final \ and use that as the key
to extract the filename but I am struggling to define this despite reading
all related posts on the subject. Any help very much appreciated.

Best regards
Dave

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Filename extract from Filepath Text String

Ron
Many thanks for this, not yet sure how it works but I'll go through it and
suss it out.
Thanks again
Dave

"Ron Rosenfeld" wrote:

On Thu, 20 Dec 2007 07:07:01 -0800, DaveyC
wrote:

Hi

I am trying to find a simple formulaic way of extracting the filename from a
filepath. I have looked at the Text related functions in Excel and they all
appear inapplicable due to the variable nature of filepaths i.e. the number
of sub-folders and the variation in naming of all elements. As an example
see below:

C:\Documents and Settings\Local Settings\My Local
Data\Graduation\campusmap.pdf

From the above I would want to extract just: campusmap.pdf

I have tried to locate the position of the final \ and use that as the key
to extract the filename but I am struggling to define this despite reading
all related posts on the subject. Any help very much appreciated.

Best regards
Dave



with your full path in A1:

=MID(A1,1+FIND(CHAR(1),SUBSTITUTE(A1,"\",CHAR(1),
LEN(A1)-LEN(SUBSTITUTE(A1,"\","")))),255)

will return everything after the last "\"

--ron

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Filename extract from Filepath Text String

On Thu, 20 Dec 2007 07:25:02 -0800, DaveyC
wrote:

Ron
Many thanks for this, not yet sure how it works but I'll go through it and
suss it out.
Thanks again
Dave



You're welcome. Thanks for the feedback.

To "suss it out", start from the middle and work outwards.


--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
extract text from string AskExcel Excel Worksheet Functions 2 October 9th 07 06:54 AM
Extract text from a string ellebelle Excel Worksheet Functions 4 June 13th 07 04:25 PM
Extract text string using MID Turk Excel Worksheet Functions 5 October 11th 06 06:39 PM
Extract text from String Dan Excel Worksheet Functions 8 July 1st 06 12:39 PM
Extract % from text string Mike Excel Worksheet Functions 5 December 1st 04 08:02 PM


All times are GMT +1. The time now is 09:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"