<< Click to Display Table of Contents >> Navigation: 3. Script Language > Filesystem-Commands > Filesystem-Commands |
MiniRobotLanguage (MRL)
COP. Command
Copy File and compare Source & Dest checksum
Intention
This command is used to copy files.
The command puts a
•zero (0) = "Operation failed or was aborted" or a
•one (1) - Copy succeeded but checksum verify failed or a
•two (2) = "operation successful"
on the stack to flag if the operation was successful or not.
New feature: COP. will compare the Source and Target File using a check sum Algorithm, to make sure the files are identical. The result is placed as 0/1/2 on TOS.
This new feature has not been tested with NTFS-direct long pathes, possibly the checksum will only work with short pathes, yet the files will still be copied as before.
Therefore a result of 1 may be Ok, when using very long pathes.
When using short pathes and the check sum does not match (1) then there may or may not be serious problems on your system:
•target file locked?
•hardware problems
•virus problems?).
Usage is as easy as:
COP.source|dest
POP.$$RER
' $$RET is now 0 (copy failed) or 1/2 (success)
MBX.Copy succeeded: $$RET
The Command has a optional network timeout.
COP.source|dest|timeout in sec.
In that case a timeout is applied. This can be helpful in Network environments like VPN's or WAN-Networks with high Latency times.
If only the folder is specified, the command will use the filename from the source.
Like in this sample:
COP.C:\Myfolder\Myfile.txt|D:\Myfolder\
The command in its default-settings does not ask for any confirmation when overwriting files. It can do serious damages to your files and data. Therefore use it with care and on your own risk!
' Copy file with COP.
VAR.$$TIM=#dtime#
: $$SRC=F:\O5-26-05.pst
: $$TAR=?desktop\Testfile.pst
COP.$$SRC|$$TAR|1
STS.DUMP
MBX.Ready: #dsince#
ENR.
If you prefer copying without using the extra safety checksum, you can use SHF. (Shell-File Operations). These times depend on the specific test system.
' Copy file with SHF.
VAR.$$TIM=#dtime#
: $$SRC=F:\O5-26-05.pst
: $$TAR=?desktop\Testfile.pst
SHF.c|pcm|$$SRC|$$TAR
STS.DUMP
MBX.Ready: #dsince#
ENR.
Syntax
COP.P1|P2[|P3]
Parameter Explanation
P1 - Variable with source-file
P2 - Variable with destination-file name. If only the folder is specified, the command will use the filename from the source.
Example:
COP.C:\Myfolder\Myfile.txt|D:\Myfolder\
P3 - (optional) Timeout in seconds, default is 1 sec.
Example
'*****************************************************
' EXAMPLE: REN. and COP.
'*****************************************************
: §§PAT=F:\Testfiles
VAR.§§FIL=§§PAT\Audiograbber.zip
VAR.§§TAC=§§PAT\recent\Target.zip
: §§TIM=2
VAR.§§TAR=§§PAT\Target.zip
VAR.§§TAB=§§PAT\Targez.zip
COP.§§FIL|§§TAB
COP.§§FIL|§§TAB|(§§TIM+3)
' If Operation was successfull then Stack contains a 1 else a 0
PRT.$$000
IVV.$$000=1
PRT.Copy was successful
ELS.
PRT. There was an Error.
EVV.
' Rename-Example
REN.§§TAR|§§TAB
' Rename-Example with File-Timeout of 5 Seconds
REN.§§TAR|§§TAB|5
END.
Remarks
Wildcards are supported. The first file that fits the description is been copied.
The command will not copy multiple files that fit a description.
The Timeout will not be applied if directories shall be renamed.
For file-operations using wildcards and more options, try SHF.
Limitations:
-
See also:
• IEF. / NEF. - If - exist - File