Sign in to follow this  
Followers 0
mobster

More help with multiple file copy (M23 please read)

4 posts in this topic

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

Thanks

Mfilecopy.au3

Share this post


Link to post
Share on other sites



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

:x


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

Share this post


Link to post
Share on other sites

mobster,

M23 has allready wrote something for me

So why not keep to the same thread? :P

but I am still stuck

And as a description of your problem that leaves a lot to be desired. :x

Let us continue this in the original topic where you have expanded a bit on that line - if PsaltyDS is happy to do that. :shifty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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

:x

Thanks a lot for your help

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0