HockeyFan Posted June 9, 2011 Share Posted June 9, 2011 I need to pull the file name out of a files full path, for example:I would like to pull "Firefox Setup 4.0.exe" from the this path: C:\Software\Firefox v4\Firefox Setup 4.0.exeI've played around with this, but I'm not getting the results that I expected. $Path = "C:\Software\Firefox v4\Firefox Setup 4.0.exe" $String = StringRight($Path, StringInStr($Path, "\", 0, -1)) MsgBox(0,"File name: ", $String)What's the best way to perform this even if the path was "C:\Firefox Setup 4.0.exe"?Thanks! Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 9, 2011 Share Posted June 9, 2011 Try with this UDF, _PathSplit. Good luck! - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
HockeyFan Posted June 9, 2011 Author Share Posted June 9, 2011 Try with this UDF, _PathSplit. Good luck! Thank you!!! That UDF works perfectly. Thanks for the pointer!! $Path = "C:\Software\Firefox v4\Firefox Setup 4.0.exe" $PathArray = _PathSplit($Path, $szDrive, $szDir, $szFName, $szExt) MsgBox(0,"File name: ", $PathArray[3] & $PathArray[4]) Link to comment Share on other sites More sharing options...
somdcomputerguy Posted June 9, 2011 Share Posted June 9, 2011 You bet. Good luck with your project. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
GMK Posted June 9, 2011 Share Posted June 9, 2011 (edited) An alternate solution: $sPath = "C:\Software\Firefox v4\Firefox Setup 4.0.exe" $aSplit = StringSplit($sPath, "\") $sFileName = $aSplit[1] & "\" & $aSplit[$aSplit[0]] Edit: Missed the front of the path. Edited June 9, 2011 by GMK Link to comment Share on other sites More sharing options...
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