Agentwho Posted July 12, 2016 Share Posted July 12, 2016 Hello, I added openfiledialog function into my script. I would like to get opened file name without direction. Example : Selected files in openfiledialog "C:\Users\Terron\Desktop\newfile.txt" => "newfile.txt" <<= I would like to get this name Which function should I add in the script? Thanks... Link to comment Share on other sites More sharing options...
Developers Jos Posted July 12, 2016 Developers Share Posted July 12, 2016 Perhaps: _PathSplit() ? Jos ahmeddzcom 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 More sharing options...
AutoBert Posted July 12, 2016 Share Posted July 12, 2016 (edited) also possible : $sRet="C:\Program Files\AutoIt3\Examples\GUI\merlin.gif" ;this simulate the returnstring of fileopendialog without $FD_MULTISELECT $sWanted=StringMid($sRet,StringInStr($sRet,'\',0,-1)+1) ;this is the combination of funcs you can use MsgBox(0,'filename only',$sWanted) if $FD_MULTISELECT is used you have to use StringSplit: #include <Array.au3> $sRet= "C:\Program Files\AutoIt3\Examples\GUI|logo4.gif|merlin.gif" ;this simulate the returnstring of fileopendialog with $FD_MULTISELECT $aWanted=StringSplit($sRet,'|',2) _arraydisplay($aWanted) ;this is the array of returnstring REMEMBER $aWandted[0]=Path, all others filenames without path Edited July 12, 2016 by AutoBert Link to comment Share on other sites More sharing options...
Agentwho Posted July 17, 2016 Author Share Posted July 17, 2016 Just now, AutoBert said: also possible : $sRet="C:\Program Files\AutoIt3\Examples\GUI\merlin.gif" ;this simulate the returnstring of fileopendialog without $FD_MULTISELECT $sWanted=StringMid($sRet,StringInStr($sRet,'\',0,-1)+1) ;this is the combination of funcs you can use MsgBox(0,'filename only',$sWanted) if $FD_MULTISELECT is used you have to use StringSplit: #include <Array.au3> $sRet= "C:\Program Files\AutoIt3\Examples\GUI|logo4.gif|merlin.gif" ;this simulate the returnstring of fileopendialog with $FD_MULTISELECT $aWanted=StringSplit($sRet,'|',2) _arraydisplay($aWanted) ;this is the array of returnstring REMEMBER $aWandted[0]=Path, all others filenames without path It is working. Thanks a lot. 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