KLBCopy.PL

Overview

ROBOCOPY.EXE halts with a "Runtime error R6002" (after a certain # files or dirs). So I decided to write my own version, in Perl. I'm striving to have the output be *identical* to Robocopy's output, so existing scripts will not break.

 

Introductory Post

Hi all,

This is my first SourceForge project. I found a bug in ROBOCOPY.EXE which gave a "Runtime error R6002" after a certain # files or # dirs. I was moving from an old drive to a newer, larger drive. I did some searching but couldn't find a tool to replace Robocopy.

So I decided to write my own.

Currently I have only written the switches I needed to finish my migration. The rest need to be written.

Anyone in an environment that uses Robocopy to move files around should be interested in this, as Robocopy is not enterprise-ready due to the runtime error condition.

I hope to release a compiled version as well, so users won't need Perl on their machines -- just download a single .EXE and away they go. (They could even rename the KLBCopy.EXE to ROBOCOPY.EXE, and then wouldn't even have to change their existing scripts!)

Thank you for your interest,
KenB
kenbeal@bigfoot.com

 

Links

Project page

 

 

The rest of this web page contains a current copy of the README.TXT file, as of FRI 12-07-2001.

 

 

 

KLBCopy.PL v0.30

Author : Ken Beal (kenbeal@bigfoot.com)
Date : FRI 11-30-2001
Homepage:
http://klbcopy.sourceforge.net



1. INTRODUCTION
2. FILES
3. DEPENDENCIES
4. USAGE
5. EXAMPLES
6. BUGS AND OTHER NOTES



1. INTRODUCTION

This is the initial release. There are many pieces missing from this program, but it's functional as-is and (more importantly) I've gotten some feedback, so I am releasing what I've got to SourceForge.

ROBOCOPY.EXE halts with a "Runtime error R6002" (after a certain # files or dirs). So I decided to write my own version, in Perl. I'm striving to have the output be *identical* to Robocopy's output, so existing scripts will not break.

Anyone in an environment that uses Robocopy to move files around should be interested in this, as Robocopy is not enterprise-ready due to the runtime error condition.

I hope to release a compiled version as well, so users won't need Perl on their machines -- just download a single .EXE and away they go. (They could even rename the KLBCopy.EXE to ROBOCOPY.EXE, and then wouldn't even have to change their existing scripts!)



2. FILES

klbcopy.pl - main program
klbtest.pl - script to perform different tests (on ROBOCOPY.EXE and
KLBCopy.pl)
testpdiff.cmd - creates and displays (in Internet Explorer) a colored "diff" of
the outputs created by klbtest.pl
alltests.cmd - script to run all the tests and display the colored "diff"
pdiff.pl - script to create a colored "diff" in HTML format



3. DEPENDENCIES

This script depends on several modules. Under Win32, you can install modules using "ppm". (Windows 2000 is my development environment, although I intend to port to Linux, given time and interest.)


Getopt::Long

This is used to get options from the command line.


File::Copy

This is used to copy the files.


Cwd

Used to get the current working directory.


Sort::PolySort

Used to sort a directory upon reading (so that the output will be the same as ROBOCOPY.EXE's).


Time::HiRes

Used to output the time at a greater resolution than one second.



4. USAGE

Usage below is from the program's usage output (run it with no parameters to get usage):


-----------------------------------------------------------------
KLBCOPY : Robust File Copy : Version 0.30 : by Ken Beal
-----------------------------------------------------------------

Started : Fri Nov 30 19:22:38 2001

Usage : KLBCOPY source destination [file [file]...] [options]

source : Source Directory (drive:\path or \\server\share\path).
destination : Destination Dir (drive:\path or \\server\share\path).
file : File(s) to copy (names/wildcards - default is "*.*").

options : /S : copy Subdirectories, but not empty ones.
/E : copy subdirectories, including Empty ones.

/T : Timestamp all destination files, including skipped files.

/R:n : number of Retries on failed copies - default is 1 million.
/W:n : Wait time between retries - default is 30 seconds.

/X : report all eXtra files, not just those selected.
/V : produce Verbose output, showing skipped files.
/L : List only - don't copy, timestamp or delete any files.

/A+:[R][A][S][H] : add the given Attributes to copied files.
/A-:[R][A][S][H] : remove the given Attributes from copied files.

/XA:[R][A][S][H] : eXclude files with any of the given Attributes.
/A : copy only files with the Archive attribute set.
/M : like /A, but remove Archive attribute from source files.

/XF file [file]... : eXclude Files matching given names/paths/wildcards.
/XD dirs [dirs]... : eXclude Directories matching given names/paths.

/XC | /XN | /XO : eXclude Changed | Newer | Older files.
/XL : eXclude Lonely files and dirs.
/IS : Include Same files.

/MOVE : Move files and dirs (delete from source after copying).

(If you're thinking that looks a lot like ROBOCOPY, it does. It's from
ROBOCOPY version 1.38, which would crash with a "runtime error R6002".
So I wrote my own version, since I copy large trees often.)



5. EXAMPLES

Let's say you wanted to copy all files from C:\DIR1 to C:\DIR2, including all subdirectories, and only retrying a single time, waiting one second between retries (this is the way I most often use the program):

klbcopy.pl C:\DIR1 C:\DIR2 /e /r:1 /w:1



6. BUGS AND OTHER NOTES

Most of the options have yet to be written. The only options that actually work right now are /S and /E (although /E fails some of the file-specific tests; however, most uses of ROBOCOPY.EXE are to copy an entire tree, not just specific files from one tree to another, so it's "good enough" for my uses).

The program will warn if the user attempts to use an option that it not written (or which fails some of the tests).


An undocumented parameter is /KLB=n, where n is a number. This will turn on debugging output, at the level n and higher (i.e., if n is 3, then all dbgprint lines of 3, 4, 5, etc. will be printed, and 1 and 2 will be ignored). To see all debugging output, use "/KLB=1". Generally I use /V=n for this feature, but since ROBOCOPY.EXE already had a /V option, I had to change the debugging option.


There is a TODO list at the end of the files KLBCopy.PL, pdiff.pl, and klbtest.pl.


pdiff.pl was a bit tricky -- in order to change the background color, I had to use tables. However, a table element can only have a single background color, so every time the color changed, I had to close the current element and create a new one. It works great though!


testpdiff.cmd expects to be run on the same drive that Internet Explorer is installed on, and expects to invoke IE from "\Program Files\Internet Explorer\IEXPLORE.EXE".


klbtest.pl expects to find "rm" and "robocopy.exe" on the path.