Sign in to follow this  
Followers 0
mobster

Multiple file copy

16 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 .

please see if you can help , I have tried to use this code .

Thanks

Mfilecopy.au3

Share this post


Link to post
Share on other sites



mobster,

Welcome to the AutoIt forum. :x

I think you are overcomplicating things a bit - take a look at this to see how to get the selected files into an array: :shifty:

#include <Array.au3> ; Just to display the result

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message,  @ScriptDir & "", "All Files (*.*)", 4 + 8 )

$FileList = StringSplit($var, "|") ; Check the Help file to see how the result is returned

_ArrayDisplay($FileList)

It should be pretty easy to copy your selected files to wherever you need by looping through the array. :P

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

mobster,

Welcome to the AutoIt forum. :x

I think you are overcomplicating things a bit - take a look at this to see how to get the selected files into an array: :shifty:

#include <Array.au3> ; Just to display the result

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message,  @ScriptDir & "", "All Files (*.*)", 4 + 8 )

$FileList = StringSplit($var, "|") ; Check the Help file to see how the result is returned

_ArrayDisplay($FileList)

It should be pretty easy to copy your selected files to wherever you need by looping through the array. :P

M23

Hi M23

Thanks for your help :-)

I am still stuck on this one can you please show me what you ment "It should be pretty easy to copy your selected files to wherever you need by looping through the array "

Thanks a lot

Share this post


Link to post
Share on other sites

mobster,

Do you understand arrays? If not, then a read of the Arrays tutorial in the Wiki would be a good idea before we go any further.

Let me know IN THIS THREAD when you are ready to move on. :x

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

Don't

:x

How would you add a progress bar to this function ? , I was able to add a progress bar to the single file copy but not to the multiple files copy.

Can you please help ?

Thanks

arrayfinal3.au3

Share this post


Link to post
Share on other sites

mobster,

I would suggest that you take the simple approach and increment a progress bar for each file copied regardless of size or time taken. So you could do something like this:

; Simulate the selection process
Global $aSelections[12] = [11, "Folder"]
For $i = 2 To 11
    $aSelections[$i] = "File " & $i - 1
Next

_multifile()

Func _multifile()

    ; Create a progress bar
    ProgressOn ( "File copying", "Your files are being copied")

    ; Set the percentage and increment values
    $iPercent = 0
    $iIncrement = 100 / ($aSelections[0] - 1)

    ; Now copy the files
    For $i = 2 To UBound($aSelections) - 1

        ; Create the file name
        $sFile = $aSelections[1] & "\" & $aSelections[$i]
        ; Determine current percentage
        $iPercent += $iIncrement
        ; Set the progress to show how and what we are doing
        ProgressSet($iPercent, "Copying " & $sFile)
        ; You would do the file copy here - you may want to add a short sleep just so the progress moves enough to be in sync
        Sleep(1000)

    Next
    ; Annonce all done
    ProgressSet(100, " ", "All files copied")
    Sleep(1000)
    ; Clear the progress
    ProgressOff()

EndFunc   ;==>_multifile

Will that do? :x

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

Thank you so much M23 :x

appreciate all your help ,the code is working perfectly :P

Share this post


Link to post
Share on other sites

mobster,

I would suggest that you take the simple approach and increment a progress bar for each file copied regardless of size or time taken. So you could do something like this:

; Simulate the selection process
Global $aSelections[12] = [11, "Folder"]
For $i = 2 To 11
    $aSelections[$i] = "File " & $i - 1
Next

_multifile()

Func _multifile()

    ; Create a progress bar
    ProgressOn ( "File copying", "Your files are being copied")

    ; Set the percentage and increment values
    $iPercent = 0
    $iIncrement = 100 / ($aSelections[0] - 1)

    ; Now copy the files
    For $i = 2 To UBound($aSelections) - 1

        ; Create the file name
        $sFile = $aSelections[1] & "\" & $aSelections[$i]
        ; Determine current percentage
        $iPercent += $iIncrement
        ; Set the progress to show how and what we are doing
        ProgressSet($iPercent, "Copying " & $sFile)
        ; You would do the file copy here - you may want to add a short sleep just so the progress moves enough to be in sync
        Sleep(1000)

    Next
    ; Annonce all done
    ProgressSet(100, " ", "All files copied")
    Sleep(1000)
    ; Clear the progress
    ProgressOff()

EndFunc   ;==>_multifile

Will that do? :x

M23

Hi

Sorry to bug you again but can you please show me how would the same thing done for a copy of a single file and a progress bar

Thanks

Share this post


Link to post
Share on other sites

mobster,

For a single file you would ideally need a progress which actually reflects the time taken. There are many scripts on the forum which show how to do that. :x

Or you could go the simple route and just use a marquee progress to indicate that something was happening: :P

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>

$hGUI = GUICreate("Test", 500, 500)
GUICtrlCreateProgress(10, 10, 400, 20, $PBS_MARQUEE)
GUICtrlSendMsg(-1, $PBM_SETMARQUEE, True, 50) ; final parameter is update time in ms
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

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

Hi

Since I am using 2 progress bars in my script I would like them to look the same so I would like to have a progress bar like the first one you wrote for me .

I also need to show some calculation and I think it would be nice to show the file name with the progress rate.

I have searched the forum and didn't find any thing like it .

Can you assit ? :x

Thanks

Share this post


Link to post
Share on other sites

mobster,

Less than 30 seconds of searching for "+file +copy +progress +multiple" threw up this UDF from Yashied. It came second in the Search results to this thread - someone's search skills obviously need a bit of sharpening. :P

Yashied's UDF seems to do everything you want - and you get the same interface whether you are copying single or multiple files. Over to you. :x

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

mobster,

Less than 30 seconds of searching for "+file +copy +progress +multiple" threw up this UDF from Yashied. It came second in the Search results to this thread - someone's search skills obviously need a bit of sharpening. :P

Yashied's UDF seems to do everything you want - and you get the same interface whether you are copying single or multiple files. Over to you. :x

M23

Thanks

How do I add the additional files (UDF) to autoit Environment ?

Which files do I need ?

Share this post


Link to post
Share on other sites

mobster,

Download the zip file from Yashied's topic and unzip the files into the same folder as your script. You then add the following line to the top of your script:

#include "Copy.au3"

The functions within the UDF are now available within your script. Note that you also need a dll file from the zip as well as the .au3 file for the UDF to function. :P

There is an example in the zip - I strongly recommend you play with it a while to see how the whole thing works. I have never used so I cannot offer much more advice than that. :x

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

The Copy UDF is pretty good and so easy to use :x


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

mobster,

Download the zip file from Yashied's topic and unzip the files into the same folder as your script. You then add the following line to the top of your script:

#include "Copy.au3"

The functions within the UDF are now available within your script. Note that you also need a dll file from the zip as well as the .au3 file for the UDF to function. :P

There is an example in the zip - I strongly recommend you play with it a while to see how the whole thing works. I have never used so I cannot offer much more advice than that. :x

M23

Hi there

The last code you sent me didnt work ,do you have a simple code for a single file copy and a progress bar which run's according to the file size ?

Thanks

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