Sign in to follow this  
Followers 0
markusss

Get only the filename from a path

3 posts in this topic

Hey!

First of all, if there is a post about this please gimme the link and dont say "Use search you n00b!". I used the search, it returned like 36 pages, went through first 2 and did't find anything... thx :P

----------------------------------------------------------------------------------------------------------------

Ok heres my question:

Is there a way to get only the filename in a path ;)?

So, lets say my path is: "C:\somefolder\somefile.txt"

And i want autoit to return: "somefile.txt"

I looked at the several string**** functions, but didn't find anything that worked :"> .

I thought StringInStr would work so i get the position where the filename starts and then use one of the trim commands. But for the StringInStr i need some kind of a placeholder, one for "*" (undefined amount of characters) and one for the end of the string.

Any solutions for this?? Would greatly appreciate it!

tdlrali (Felix)

Share this post


Link to post
Share on other sites



$FilePath = "C:\somefolder\somefile.txt"
$File = StringTrimLeft($FilePath,StringInStr($FilePath,"\",0,-1))


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanx :P

Was too easy! ^^

+10 points honor for JdeB ;)

tdlrali

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0