Commands & Syntax > Commands > Folder Manipulation >

www.MacroToolworks.com

COPY - < dircopy >() ... [Pro]

 

Folder COPY
<dircopy>("Source","Destination",Subfolders,Unused,Retries,Variable for number of processed files,Variable for number of failures,"Log errors","Additional options")
Available in: Professional edition

Copies directory including all subdirectories. The command continues copying files even if some files fails to be copied. Failed files are reported in report file and also number of failures can be saved in user defined variable so that errors can be handled programmatically.

 

#

Parameter name

Parameter description

1

Source

Full path to the source directory (e.g., "c:\mydocuments").

2

Destination

Full path to the destination directory (e.g., "c:\backup").

3

Subfolders

Must be 0.

4

Unused

Must be 0.

5

Retries

If the copy fails the command can retry to copy later. This parameter tells the number of retries.

6

Variable for number of processed files

This variable receives the number of files copied. This parameter can be left blank.

7

Variable for number of failures

This variable receives the number of failures. This parameter can be left blank.

8

Log errors

If a file cannot be copied then it is recorded in report file. This parameter can be left blank.

9

Additional options

Additional parameters: "-pr" - show progress window "-on" - overwrite file only if it is newer.

 

Example (Macro Steps):

 

1

<#> <#> This macro copies directory you select to other directory you select.

2

Macro execution: ONLY COMMANDS

3

Message SHOW "" : "Select folder you want to copy." (other parameters: x = 100, y = 100, Window title = Message, Buttons = None, Timeout (seconds) = , Always on top = ).

4

Variable OPERATION "SELECT_FOLDER" (Variable for result = vDirSource, Input text/variable = , Parameter 1 = Select Source Folder, Parameter 2 = , Parameter 3 = 0)

5

Procedure CALL: ExitOnCancel with parameters ()

6

Message CLOSE

7

Message SHOW "" : "Select destination folder." (other parameters: x = 100, y = 100, Window title = Message, Buttons = None, Timeout (seconds) = , Always on top = ).

8

Variable OPERATION "SELECT_FOLDER" (Variable for result = vDirDest, Input text/variable = , Parameter 1 = Select Destination Folder, Parameter 2 = , Parameter 3 = 0)

9

Procedure CALL: ExitOnCancel with parameters ()

10

Message CLOSE

11

Message SHOW "" : "Folder copy is in progress. Please wait...." (other parameters: x = 100, y = 100, Window title = Message, Buttons = None, Timeout (seconds) = , Always on top = ).

12

Folder COPY from "vDirSource" to "vDirDest" (Subfolders = No, Retries = 3, Variable for number of processed files = , Variable for number of failures = vFail, Log errors = %TEMP%\DirCopyFailuresReport.txt, Additional options = -pr -on )

13

Message CLOSE

14

<#> <#> --------------------------------------------------------------------

15

Procedure BEGIN: ExitOnCancel with parameters ()

16

IF STRING _vCanceled==1

17

Macro EXIT

18

ENDIF

19

Procedure END

20

<#> <#> --------------------------------------------------------------------

Example (Plain Text):

 

<#> This macro copies directory you select to other directory you select.

<#>

<cmds>

 

<msg>(100,100,"Select folder you want to copy.","Message",0)

<var_oper>(vDirSource,"",SELECT_FOLDER,"Select Source Folder","", "0")

<proc_call>(ExitOnCancel,)

<msgoff>

 

<msg>(100,100,"Select destination folder.","Message",0)

<var_oper>(vDirDest,"",SELECT_FOLDER,"Select Destination Folder","", "0")

<proc_call>(ExitOnCancel,)

<msgoff>

 

<msg>(100,100,"Folder copy is in progress. Please wait....","Message",0)

<dircopy>("vDirSource","vDirDest",0,0,3,,vFail,"%TEMP%\DirCopyFailuresReport.txt","-pr -on ")

<msgoff>

 

<#> --------------------------------------------------------------------

 

<proc_def_begin>(ExitOnCancel,)

<if_str>("_vCanceled==1")

   <exitmacro>

<endif>

<proc_def_end>

 

<#> --------------------------------------------------------------------