mobster Posted January 8, 2011 Share Posted January 8, 2011 Hi I am looking for a function that will be able to copy multiple files but the file selction must be done with with the following function : FileOpenDialog($message, @WindowsDir & "", "All files (*.*)", 4 + 8 ), I was having problems transfering all files from the function result to an array . attching files M23 has allready wrote something for me but I am still stuck ,M23 or some else can you please help ThanksMfilecopy.au3 Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 8, 2011 Share Posted January 8, 2011 Note the results of FileOpenDialog() in the help file: Success: Returns the full path of the file(s) chosen. Results for multiple selections are "Directory|file1|file2|..." So if you simply StringSplit() the returned list with this you will get your array. By checking the count of results in [0] of the array you can tell if there were multiple or single selections. In the demo below you could put FileCopy() or whatever else you want done in place of _Usefile(). Demo: #include <Array.au3> $sSelections = FileOpenDialog("Pick multiple files", @WindowsDir & "", "All files(*.*)", 4 + 8) If @error Then Exit ConsoleWrite("$sSelections = " & $sSelections & @LF) $aSelections = StringSplit($sSelections, "|") _ArrayDisplay($aSelections, "$aSelections") If $aSelections[0] = 1 Then ; Single selection _UseFile($aSelections[1]) ElseIf $aSelections[0] > 1 Then ; Multiple selections For $n = 2 To UBound($aSelections) - 1 _UseFile($aSelections[1] & "\" & $aSelections[$n]) Next EndIf Func _UseFile($sFile) ConsoleWrite("Debug: _Usefile(): $sFile = " & $sFile & @LF) EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 9, 2011 Moderators Share Posted January 9, 2011 mobster,M23 has allready wrote something for meSo why not keep to the same thread? but I am still stuckAnd as a description of your problem that leaves a lot to be desired. Let us continue this in the original topic where you have expanded a bit on that line - if PsaltyDS is happy to do that. 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...
mobster Posted January 9, 2011 Author Share Posted January 9, 2011 Note the results of FileOpenDialog() in the help file: So if you simply StringSplit() the returned list with this you will get your array. By checking the count of results in [0] of the array you can tell if there were multiple or single selections. In the demo below you could put FileCopy() or whatever else you want done in place of _Usefile(). Demo: #include <Array.au3> $sSelections = FileOpenDialog("Pick multiple files", @WindowsDir & "", "All files(*.*)", 4 + 8) If @error Then Exit ConsoleWrite("$sSelections = " & $sSelections & @LF) $aSelections = StringSplit($sSelections, "|") _ArrayDisplay($aSelections, "$aSelections") If $aSelections[0] = 1 Then ; Single selection _UseFile($aSelections[1]) ElseIf $aSelections[0] > 1 Then ; Multiple selections For $n = 2 To UBound($aSelections) - 1 _UseFile($aSelections[1] & "\" & $aSelections[$n]) Next EndIf Func _UseFile($sFile) ConsoleWrite("Debug: _Usefile(): $sFile = " & $sFile & @LF) EndFunc Thanks a lot 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