dirty Posted February 27, 2010 Share Posted February 27, 2010 (edited) I was wondering why FileOpenDialog ("Select files", "", "UT3 files (*.upk;*.u;*.ut3)",1+4) Would return values as C:\Folder\Filename.upk Filename2.upk Filename3.upk instead of C:\Folder\Filename.upk C:\Folder\Filename2.upk C:\Folder\Filename3.upk ? Is there a way to get all selected files return full path for each of them ? One other thing is that (i am using "guictrlcreatelist") returned value is 1 line separated by '|' character which if i was to use guictrlcreateedit would pose a problem and output it to edit box as a single line. Thats kinda why i went with inputbox instead of editbox. I was looking into help file (like i always do before asking for help) i found that Opt("GUIDataSeparatorChar", "Character") would do the trick caz all i wanted is to separate them with @CRLF so i would get new line each time, but that didnt work and i cant find any examples on that option anywhere i looked. Goal is simple, i would have to give a command to console application to process list of selected files one by one but not sure how am i going to do that yet. All i have done is created GUI with all $vars Cases Ifs and error checks and all i need even $vars for commands, all thats left is this confusing part where lines are not separated as i was expecting (with new line) I am using: Opt("GUIDataSeparatorChar", @CRLF) $UT3List = GUICtrlCreateedit ("",10,180,380,192) $UT3FilesBrowser = FileOpenDialog ("Select files", "", "UT3 files (*.upk;*.u;*.ut3)",1+4) GUICtrlSetData ($UT3List, $UT3FilesBrowser, "Edit") Anyone have time to help ? Edited February 27, 2010 by dirty Link to comment Share on other sites More sharing options...
Developers Jos Posted February 27, 2010 Developers Share Posted February 27, 2010 I would think the helpfile is clear enough about what is returned so the rest is up to you to arrange in your script.Return ValueSuccess: Returns the full path of the file(s) chosen. Results for multiple selections are "Directory|file1|file2|..." 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...
dirty Posted February 27, 2010 Author Share Posted February 27, 2010 Its the | i want to replace with @crlf, but Opt("GUIDataSeparatorChar", @CRLF)is not working or replacing | with @crlf Link to comment Share on other sites More sharing options...
Developers Jos Posted February 27, 2010 Developers Share Posted February 27, 2010 Its the | i want to replace with @crlf, but Opt("GUIDataSeparatorChar", @CRLF)is not working or replacing | with @crlfAs I said: You need to do this in your code after having received the selected files.Its is really easy when you set your mind to it: StringReplace() for example can do miracles for you. 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...
dirty Posted February 28, 2010 Author Share Posted February 28, 2010 As I said: You need to do this in your code after having received the selected files. Its is really easy when you set your mind to it: StringReplace() for example can do miracles for you. Oh thats right i completely forgot about strings managment. Thanks Hey while am at it, can you please tell me if there is anyway (maybe using strings) i can get FileOpenDialog to return "Directory\file1" "Directory\file2..." instead of "Directory|file1|file2|..." ? Caz "Directory|file1|file2|..." is bad and i cant use it at all. Keep in mind that directory could change from file to file. REason why is "Full path1\file1.ext" "Full path2\file2.ext" works and "Full path1\file1.ext|file2.ext" doesnt. I figured that trying to use command prompt to execute console applications commands. That app wants full path and file name wraped around with quotes for each filename and i have no clue how to accomplish this even by using strings. There could be 100's of files and i cant string them all. Theres gotta be something i could do (not without your help) Thanks Jos. Link to comment Share on other sites More sharing options...
GEOSoft Posted February 28, 2010 Share Posted February 28, 2010 (edited) $sFiles = FileOpenDialog(......);; If you can't fill this in then STOP HERE! If StringInStr($sFiles, "|") Then $aFiles = StringSplit($sFiles, "", 2) For $i = 1 to Ubound($aFiles) -1 $sStr = '"' & $aFiles[0] & "\" & $aFiles[$i] & '"' MsgBox(0, "Result", $sStr);; Do something with the results here Next Else $sStr = '"' & $sFiles & '"' ;; Do something if it is only a single file selected EndIf Edited February 28, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Developers Jos Posted February 28, 2010 Developers Share Posted February 28, 2010 (edited) Hey while am at it, can you please tell me if there is anyway (maybe using strings) i can get FileOpenDialog to return "Directory\file1" "Directory\file2..." instead of "Directory|file1|file2|..." ?Caz "Directory|file1|file2|..." is bad and i cant use it at all. Keep in mind that directory could change from file to file.As I said: You need to do this in your code after having received the selected files.As Geosoft shown you just do that in your script. Edited February 28, 2010 by Jos too early in the morning 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...
GEOSoft Posted February 28, 2010 Share Posted February 28, 2010 As Geosoft shown you just do that in your script. below a little modification to it to resolve some issues. $sFiles = FileOpenDialog(...);; If you can't fill this in then STOP HERE! If StringInStr($sFiles, "|") Then $aFiles = StringSplit($sFiles, "", 2) For $i = 2 To $aFiles[0] $sStr = '"' & $aFiles[1] & "\" & $aFiles[$i] & '"' MsgBox(0, "Result", $sStr);; Do something with the results here Next Else $sStr = '"' & $sFiles & '"' MsgBox(0, "Result", $sStr);; Do something with the results here ;; Do something if it is only a single file selected EndIf Hmmmmm. I don't see any issues with my version but I do with yours. Check out the 2 in StringSplit(). From the help file flag = 2, disable the return of the count in the first element - effectively makes the array 0-based (must use UBound() to get the size in this case). George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Developers Jos Posted February 28, 2010 Developers Share Posted February 28, 2010 Hmmmmm. I don't see any issues with my version but I do with yours. Check out the 2 in StringSplit().From the help filemeaculpa I guess it is to early still. You did however have a little typo in the receiving array variable name. Thanks george. 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...
GEOSoft Posted February 28, 2010 Share Posted February 28, 2010 meaculpa I guess it is to early still. You did however have a little typo in the receiving array variable name. Thanks george.Right you are so lets call it a draw. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Developers Jos Posted February 28, 2010 Developers Share Posted February 28, 2010 Right you are so lets call it a draw.yea.. I can really tell that I am not scripting way as much as I used too a couple of years ago and regularly miss these addition/changes made to functions.Only scripting I do these days are the supporting scripts like Autoit3Wrapper. 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...
dirty Posted March 1, 2010 Author Share Posted March 1, 2010 (edited) oh cool guys thanks a bucket for your help. ill get my dirty hands on your examples as soon as i wash the clue off of them Later that dayJust tried your examples and here is what i got.In editbox after selecting multiple files with fileopendialog i get.D:\Unreal Tournament 3\UTGame\CookedPC|Core.u|Editor.u|Engine.uWith your example in place, $sStr returns "63\D"I dont understand what does that mean but what the hell.Then i tried it your script only without adding git to my script and nothing at happened at all after selecting multiple files.It wonly worked when selected single file.IN your code i only modifiedFileOpenDialog ("Select files", "", "UT3 files (*.upk;*.u;*.ut3)",1+4)First example returns D\ for multiple select and kipped showing this for each letter and second example returned nothing at all for multi select.Did i forget to add a #include <filename.au3> to your examples ?I need to modify this:D:\Unreal Tournament 3\UTGame\CookedPC|Core.u|Editor.u|Engine.uto this:"D:\Unreal Tournament 3\UTGame\CookedPC\Core.u" "D:\Unreal Tournament 3\UTGame\CookedPC\Editor.u\" "D:\Unreal Tournament 3\UTGame\CookedPC\Engine.u"So that each file has full path and wrapped with quotes. Do you guys have any other examples please ? Edited March 1, 2010 by dirty Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2010 Moderators Share Posted March 1, 2010 dirty, This works for me: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $UT3List = GUICtrlCreateedit ("",10,180,380,192) GUISetState() $UT3FilesBrowser = FileOpenDialog ("Select files", "", "AU3 files (*.au3)",1+4) ; See if multiple files have been selected If StringInStr($UT3FilesBrowser, "|") Then ; Multiple files selected so transform into array $aFileList = StringSplit($UT3FilesBrowser, "|") ; Now add the filenames into the edit, preceded with the path and ending with @CRLF For $i = 2 To $aFileList[0] GUICtrlSetData($UT3List, $aFileList[1] & $aFileList[$i] & @CRLF, "1") Next Else ; Only a single file selected, so add directly to the edit GUICtrlSetData($UT3List, $UT3FilesBrowser & @CRLF) EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I hope it is clear enough. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
dirty Posted March 1, 2010 Author Share Posted March 1, 2010 (edited) dirty, This works for me: I hope it is clear enough. :mellow: M23 [/quote] "D:\Unreal Tournament 3\UTGame\CookedPCfile1.u" "D:\Unreal Tournament 3\UTGame\CookedPCfile2.u" "D:\Unreal Tournament 3\UTGame\CookedPCfile3.u" 1 problem D:\Unreal Tournament 3\UTGame\CookedPCCore.u is actually D:\Unreal Tournament 3\UTGame\CookedPC\file1.u Backslash was missing. Also for each file i needed quotes like "D:\Unreal Tournament 3\UTGame\CookedPC\file1.u" "D:\Unreal Tournament 3\UTGame\CookedPC\file2.u" so i modified your example to wrap each result with quotes.GUICtrlSetData($UT3List, '"' & $aFileList[1] &'\' & $aFileList[$i] & '" ', "1") This will add backslash to before each filename.ext and wrap its full path with quotes. Man i gotta learn how to with with For $var = 1 to &var2 = 2 things, otherwise i'd be asking for help all the time. Thank you so much Melba23 Edited March 1, 2010 by dirty Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2010 Moderators Share Posted March 1, 2010 dirty,Sorry about the missing \. Still catches me out from time to time! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GEOSoft Posted March 1, 2010 Share Posted March 1, 2010 I hope it is clear enough. M23<grumble> You and your damn 1 based arrays </grumble>I have to rewrite so much code to return 0 based arrays that it's becoming tedious.Look at the built in AutoIt functions that return arrays, 0 based. Look at the majority of UDFs that people write, 1 based. Half of those 1 based arrays are because of StringSplit() and not using the "2" flag. I know, it's because that flag wasn't available for a long time but that doesn't mean that we have to live with it now. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 1, 2010 Moderators Share Posted March 1, 2010 George,I did not write StringSplit, nor did I arrange for FileOpenDialog to return that ridiculous string! And to think I was cheering on Canada in the ice hockey final last night - some people have no sense of gratitiude! M23P.S. Besides, until someone changes UBound to return the last element index as you would expect, I am more than happy with the count in [0]! Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GEOSoft Posted March 1, 2010 Share Posted March 1, 2010 George, I did not write StringSplit, nor did I arrange for FileOpenDialog to return that ridiculous string! And to think I was cheering on Canada in the ice hockey final last night - some people have no sense of gratitiude! M23 P.S. Besides, until someone changes UBound to return the last element index as you would expect, I am more than happy with the count in [0]! I just needed someone to pick on. And Ubound($array) -1 doesn't bother me at all and I even use it for 1 based arrays. Although I must admit it would be nicer if it did return the last element index. Unfortunatly that would be a major script breaker, but we've done those before too. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
dani Posted March 1, 2010 Share Posted March 1, 2010 (edited) As UBound basically is the equivalent of .size() or .length() in other programming languages I strongly disagree with making it return the index of the last element. It should return the number of elements, as it does right now. The following ugly syntax (imo) For $i = 0 To Ubound($anArray)-1 ; Do Something with $anArray[$i] Next ... should just be replaced by something much more elegant like Foreach $anArray as $anElement ; Do Something with $anElement FEnd Then we wouldn't have people discuss what UBound should return -- only that it should be renamed to ArraySize Don't get me wrong, For loops are fine but I do not in any way admire it's syntax when used with arrays. Edited March 1, 2010 by d4ni Link to comment Share on other sites More sharing options...
dirty Posted March 2, 2010 Author Share Posted March 2, 2010 (edited) what a debate By the way my thing is almost over and i was wondering yif you guys could help me with one last thing.How to search directory and and its subdirectories for .uz3 file formats and then move them to other place ?Kinda like $Dir = "C:\" $Search = FileFindFirstFile ($Dir & "*") While 1 $FindNext = FileFindNextFile ($Search) $GetExt = StringRight ($FindNext,4) FileCopy ($Dir & $FindNext & "*.txt", @DesktopDir,1) MsgBox(0,'',$FindNext & ' copied') If $FindNext = "" Then ExitLoop WEndSomehow it copies files only after loop exits or am just going crazy after all today all i did was typing and eating.All this does is shows files only from C:\ but not its sub directories.By the way, i totaly agree with renaming some of the syntax due to me always trying to typeDirOpenDialog when its actually FileSelectFolderThen why FileOpenDialog is not FileSelectFile ? Now that would be stupid dont you think ? fileselectfile hahahahah !StrangeEdit:I tried to play with array's$Dir = "C:\" $array = _FileListToArray ($Dir,'*',2) _ArrayDelete ($array,0) $result = _ArrayToString ($array,' ') MsgBox(0,'',$result)It gives me names of all sub folders but i am not sure how to use that to my advantage. Edited March 2, 2010 by dirty 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