Get File Name from Path

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

How can I get just the filename mypic1.jpg from below path? The path can
change to other sub folders, so I'd like to get the text after the last "\".

PATH

C:\data\access\mypic1.jpg
 
Hi Scott,

you can do a reverse search for \
and then take the RIGHT characters from the string for the
filename

dim mPos as integer, mFilename as string
mPos = instrRev(FilePath_variable,"\")

mFilename = right(FilePath_variable,
len(FilePath_variable)-mPos)


Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
Hi Duane,

You are so clever!

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
Your solution is more robust since my solution requires the file to exist.
If there is no file of that spec, the Dir() won't return any value.
 
Hi Duane,

Thanks ... did I just get a consolation prize ;)

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
No, I think you get the Gold and I get the Silver since I took a short cut
that might lead to a tree or rock.
 
thx.

Crystal said:
Hi Scott,

you can do a reverse search for \
and then take the RIGHT characters from the string for the filename

dim mPos as integer, mFilename as string
mPos = instrRev(FilePath_variable,"\")

mFilename = right(FilePath_variable, len(FilePath_variable)-mPos)


Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
you are funny, Duane ;) and you must be a skiier too ;)

I am happy you posted that -- it is something else to think
about...

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 
you're welcome, Scott ;) happy to help

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top