Crazyglew Posted April 24, 2008 Posted April 24, 2008 I'm pretty new to AutoIt, so forgive me if this has been covered or is in the wrong forum, but I can't find it. How can I edit a path that I have received in a variable? I created a browse button that will look for an excel file, and I want to filter out just the file name from the path: EX. path = c:\folder\FileName.xls I would like to extract the FileName.xls part to add to a variable for use later on in the script. (And the c:\folder\ part will not always be the same path) Any help is appreciated. Thanks!
covaks Posted April 24, 2008 Posted April 24, 2008 Here's two different ways you might try: $path = "c:\folder\FileName.xls" $path = StringRight($path,StringLen($path)-StringInStr($path,"\",0,-1)) msgbox(1,"",$path) ; A second way, maybe easier to understand $path = "c:\folder\FileName.xls" $path = StringSplit($path,"\") msgbox(1,"",$path[$path[0]])
Crazyglew Posted April 24, 2008 Author Posted April 24, 2008 Here's two different ways you might try: $path = "c:\folder\FileName.xls" $path = StringRight($path,StringLen($path)-StringInStr($path,"\",0,-1)) msgbox(1,"",$path) ; A second way, maybe easier to understand $path = "c:\folder\FileName.xls" $path = StringSplit($path,"\") msgbox(1,"",$path[$path[0]]) That's EXCELLENT. Exactly what I was looking for. Thank You!
redsleeves Posted April 24, 2008 Posted April 24, 2008 You may also want to check out the _PathSplit function. From the help file: #include <file.au3> Dim $szDrive, $szDir, $szFName, $szExt _PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt) MsgBox(0,"_PathSplit",$szFName& $szExt)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now