Jump to content

Copy UDF


Yashied
 Share

Recommended Posts

:) Sorry, that probably didn't come accross the way I intended it. I didn't mean it with any degree of contempt. I know how difficult it is to write a UDF from scratch, and I would absolutely be lost without the help of members of this forum. Your script may not fit my needs 100%, but it will get me about 90% of the way there, so there is no reason I couldn't just tweak it to get it the other 10%. I never intended to imply your script was not worthy of use or reference, and I would have to write a new one from scratch. This will be the last post in this particular thread about a _FileListToArray alternative, as it is starting to get off topic (I appologize for that). Just know, I greatly respect your work and efforts, as well as those of everyone.
Link to comment
Share on other sites

  • 2 weeks later...

The library has been updated to version 1.3. Now you can copy or move a directories with all its sub-directories and files (see examples). Also added function _Copy_Pause() to suspend and resume a process of copying or moving files. For more information, see description of each function within the library.

:)

Link to comment
Share on other sites

  • 2 weeks later...

I know it is a Copy udf :) ..but have you considered to implement also the support to Move files? Because if an user desire to move files with your udf have to copy+delete them, but it needs much more time than move process if is done on the same volume.

Anyway thanks for the very good udf! It is used as coping core of DropIt software. :)

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

Copy UDF support in full as copying and moving.

_Copy_CopyDir() - Copying a directory.

_Copy_CopyFile() - Copying a file.

_Copy_MoveDir() - Moving a directory.

_Copy_MoveFile() - Moving a file or directory (source and destination directories must be on the same drive).

This UDF is based on two API functions:

CopyFileEx()

MoveFileWithProgress()

Edited by Yashied
Link to comment
Share on other sites

D'oh! :) ..I'm getting older..really sorry for this my lack.

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • 6 months later...

A question about this UDF: shared folders and/or UNC paths are supported as destination paths?

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

Very good :mellow: ..and what is the specific syntax to be used? thanks!

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • 3 weeks later...

The library has been updated to version 1.4. Added ability to specify a user-defined callback function to call when a file of the same name as the currently copying or moving file already exists in the destination directory. This is actual when you copy or move directories because it is done recursively, and you cannot know in advance whether exist a file of the same name in the target directory. This callback can help you decide whether to overwrite an existing file, or not. See description for the _Copy_CopyDir() and _Copy_MoveDir() functions for more information.

Note that this library only works with Copy.dll version 1.4 (inside archive).

Link to comment
Share on other sites

  • 1 month later...

I updated Copy UDF in a script to the last version. The script opens the dll at the beginning of the copy and close it at the end, so it is possible to open and close the dll more times in a session of the script.

I found that _Copy_CloseDll() returns error 4 after the first copy and so the script is closed the next time _Copy_OpenDll() is called. I modified the "Example 3" to open dll after Copy click and close dll completed the copy, to test the problem. The issue persists also in this simple code. I hope to be helpful with this report and sorry for my old approximate posts.

Update: this is the modified example.

#Include <EditConstants.au3>
#Include <GUIConstantsEx.au3>

#Include "Copy.au3"

Opt('MustDeclareVars', 1)
Opt('TrayAutoPause', 0)

Global $hForm, $Input1, $Input2, $Button1, $Button2, $Button3, $Button4, $Data, $Msg, $Path, $Progress, $State, $Copy = False, $Pause = False
Global $Source = '', $Destination = ''

$hForm = GUICreate('MyGUI', 360, 163)
GUICtrlCreateLabel('Source:', 14, 23, 58, 14)
$Input1 = GUICtrlCreateInput('', 74, 20, 248, 19, BitOR($ES_AUTOHSCROLL, $ES_LEFT, $ES_MULTILINE))
GUICtrlSetState(-1, $GUI_DISABLE)
$Button1 = GUICtrlCreateButton('...', 326, 19, 21, 21)
GUICtrlCreateLabel('Destination:', 14, 55, 58, 14)
$Input2 = GUICtrlCreateInput('', 74, 52, 248, 19, BitOR($ES_AUTOHSCROLL, $ES_LEFT, $ES_MULTILINE))
GUICtrlSetState(-1, $GUI_DISABLE)
$Button2 = GUICtrlCreateButton('...', 326, 51, 21, 21)
$Progress = GUICtrlCreateProgress(14, 94, 332, 16)
$Button3 = GUICtrlCreateButton('Copy', 135, 126, 80, 21)
$Button4 = GUICtrlCreateButton(';', 326, 126, 21, 21)
GUICtrlSetFont(-1, 10, 400, 0, 'Webdings')
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()

While 1
    If $Copy Then
        $State = _Copy_GetState()
        If $State[0] Then
            $Data = Round($State[1] / $State[2] * 100)
            If GUICtrlRead($Progress) <> $Data Then
                GUICtrlSetData($Progress, $Data)
            EndIf
        Else
            Switch $State[5]
                Case 0
                    GUICtrlSetData($Progress, 100)
                    MsgBox(64, '', 'File was successfully copied.', 0, $hForm)
                Case 1235 ; ERROR_REQUEST_ABORTED
                    MsgBox(16, '', 'File copying was aborted.', 0, $hForm)
                Case Else
                    MsgBox(16, '', 'File was not copied.' & @CR & @CR & $State[5], 0, $hForm)
            EndSwitch
            GUICtrlSetData($Progress, 0)
            GUICtrlSetState($Button1, $GUI_ENABLE)
            GUICtrlSetState($Button2, $GUI_ENABLE)
            GUICtrlSetState($Button4, $GUI_DISABLE)
            GUICtrlSetData($Button3, 'Copy')
            GUICtrlSetData($Button4, ';')
            $Copy = 0
   _Copy_CloseDll()
   MsgBox(16, "Error Closing", @error)
        EndIf
    EndIf
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button1
            $Path = FileOpenDialog('Select Source File', StringRegExpReplace($Source, '[^]*Z', ''), 'All Files (*.*)', 3, StringRegExpReplace($Source, '^.*', ''), $hForm)
            If $Path Then
                GUICtrlSetData($Input1, $Path)
                $Source = $Path
            EndIf
        Case $Button2
            $Path = FileOpenDialog('Select Destination File', StringRegExpReplace($Destination, '[^]*Z', ''), 'All Files (*.*)', 2, StringRegExpReplace($Source, '^.*', ''), $hForm)
            If $Path Then
                GUICtrlSetData($Input2, $Path)
                $Destination = $Path
            EndIf
        Case $Button3
            If $Copy Then
                _Copy_Abort()
            Else
                If (Not $Source) Or (Not $Destination) Then
                    MsgBox(16, '', 'The source and destination file names must be specified.', 0, $hForm)
                    ContinueLoop
                EndIf
                If FileExists($Destination) Then
                    If MsgBox(51, '', $Destination & ' already exists.' & @CR & @CR & 'Do you want to replace it?', 0, $hForm) <> 6 Then
                        ContinueLoop
                    EndIf
                EndIf
    If Not _Copy_OpenDll() Then
     MsgBox(16, "Error Opening", @error)
     Exit
    EndIf
                GUICtrlSetState($Button1, $GUI_DISABLE)
                GUICtrlSetState($Button2, $GUI_DISABLE)
                GUICtrlSetState($Button4, $GUI_ENABLE)
                GUICtrlSetData($Button3, 'Abort')
                _Copy_CopyFile($Source, $Destination)
                $Copy = 1
            EndIf
        Case $Button4
            $Pause = Not $Pause
            If $Pause Then
                GUICtrlSetData($Button4, '4')
            Else
                GUICtrlSetData($Button4, ';')
            EndIf
            _Copy_Pause($Pause)
    EndSwitch
WEnd
Edited by Lupo73

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • 1 month later...

I updated Copy UDF in a script to the last version. The script opens the dll at the beginning of the copy and close it at the end, so it is possible to open and close the dll more times in a session of the script.

I found that _Copy_CloseDll() returns error 4 after the first copy and so the script is closed the next time _Copy_OpenDll() is called. I modified the "Example 3" to open dll after Copy click and close dll completed the copy, to test the problem. The issue persists also in this simple code. I hope to be helpful with this report and sorry for my old approximate posts.

Fixed. Please download again.

Link to comment
Share on other sites

Thanks! It works fine :)

SFTPEx, AutoCompleteInput_DateTimeStandard(), _ImageWriteResize()_GUIGraduallyHide(): some AutoIt functions.

Lupo PenSuite: all-in-one and completely free selection of portable programs and games.

DropIt: a personal assistant to automatically manage your files.

ArcThemALL!: application to multi-archive your files and folders.

Link to comment
Share on other sites

  • 2 months later...

Yashied,

very well done! :thumbsup:

I would like to incorporate your UDF into one of my scripts.

1) Currently I use 'FileCopy()' (flag = 9) because of copying file by file. Can this be managed somehow with the help of your UDF?

2) I am not very familiar with loading/unloading DLLs. Is is possible to embed 'Copy(_x64).dll'?

Greets,

-supersonic.

EDIT:

1) I have wrote a litte wrapper to imitate the functionality of 'FileCopy()' but I'm not happy with the result. I think the code is somehow slow. Maybe there is a way to speed it up by using mainly the functionality of your UDF?

2) I have searched the forum and found the MemoryDll UDF by Ward ( ). I brought both UDFs together and it seems to work fine. Please, could you evaluate if your UDF is "embedded DLL ready" and will work in all cases you defined?

EDIT (2):

I removed the attached file '_FileCopy.zip' due to the fact that there is a hugh bug in it. I will release a fixed version very soon. Please see (one of) my following post(s).

Copy_MemoryDll.zip

Edited by supersonic
Link to comment
Share on other sites

  • 2 weeks later...

Yashied,

attached is a working example of the '_FileCopy()' UDF. This function can only handle file by file - that means wildcards (*, ?) are not supported. Furthermore an existing file will be overwritten and its destination directory structure will be created if it doesn't exist (like 'FileCopy()' with 'flag = 9').

This UDF is still somehow slow - maybe someone can help me to speed it up???

Greets,

-supersonic.

_FileCopy.zip

Edited by supersonic
Link to comment
Share on other sites

  • 1 month later...

Hi Yashield,

This is awesome UDF. I am currently working on a tool which needs to copy Directories from one location to another. some of the directories are having more than 1GB data.in those situation the GUI get freezes.. do you have any suggestion how to use this UDF in my code. Please have a look at this hope you can help me.. Please!!!!

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...