Jump to content

Get only the filename from a path


 Share

Recommended Posts

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)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...