njdev1k Posted August 30, 2008 Share Posted August 30, 2008 I am trying to return just the file name and not the entire path to the file using FileOpenDialog to a label, how do I break it down to just file name selected? Partial code below FileInstall("C:\TargetReset\TargetReset.exe", $destination2, 1) FileInstall("C:\TargetReset\radesdkpia.dll", $destination3, 1) FileInstall("C:\TargetReset\TargetReset.pdb", $destination4, 1) FileInstall("C:\TargetReset\TargetReset.vshost.exe", $destination5, 1) FileInstall("C:\TargetReset\info.txt", $destination6, 1) $filelbl = GuiCtrlCreateLabel("Select profile to reset", 10, 20, 100, 20) $filebutton = GuiCtrlCreateButton("Select Profile", 10, 40, 100, 20) $filelbl2 = GuiCtrlCreateLabel("Select cab file GUID to reset", 260, 20, 150, 20) $filebutton2 = GuiCtrlCreateButton("Select Cab", 280, 40, 100, 20) $info1 = GUICtrlCreateLabel("Profile: ", 10, 80, 480, 40) $info2 = GUICtrlCreateLabel("GUID: ", 10, 160, 300, 20) ;$Proglbl = GuiCtrlCreateLabel("Target Reset Utility", 10, 10, 220, 20) ;$guidlbl = GuiCtrlCreateLabel("Enter GUID to reset", 10, 80, 220, 20) ;$guid = GUICtrlCreateInput("", 10, 100, 300, 20) $Runlbl = GuiCtrlCreateLabel("Execute against target", 10, 220, 140, 20) $Runbutton = GuiCtrlCreateButton("Run", 10, 240, 100, 20) $Cancelbutton = GuiCtrlCreateButton("Quit", 280, 240, 100, 20) $var = "" $bLoop = 1 While $bLoop = 1 $msg = GuiGetMsg() Select Case $msg = -3 Exit Case $msg = $filebutton $var = FileOpenDialog("Select profile", @ScriptDir, "Profiles (*.profile)", 1) $chosen = ($var) GUICtrlSetData($info1, "Profile: " & $chosen) $bLoop = 1 Link to comment Share on other sites More sharing options...
Zedna Posted August 30, 2008 Share Posted August 30, 2008 Look at _PathSplit() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
rasim Posted August 30, 2008 Share Posted August 30, 2008 njdev1kExample:$sFile = FileOpenDialog("Please select a file", "", "All (*.*)") If @error Then Exit $fName = StringRegExpReplace($sFile, "^.*\\", "") MsgBox(0, "File name", $fName) Link to comment Share on other sites More sharing options...
njdev1k Posted August 30, 2008 Author Share Posted August 30, 2008 njdev1k Example: $sFile = FileOpenDialog("Please select a file", "", "All (*.*)") If @error Then Exit $fName = StringRegExpReplace($sFile, "^.*\\", "") MsgBox(0, "File name", $fName) StringRegExpReplace worked perfect, thanks for your help! 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