home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
utlos2.zip
/
Doc
/
ccp.doc
next >
Wrap
Text File
|
1998-02-07
|
12KB
|
255 lines
$Id: ccp.doc 1.13 1998/02/08 02:02:01 brian Exp $
ccp : Conditional Copy
By: Brian Yoder
(c) Copyright International Business Machines Corporation 1998
All rights reserved.
The ccp command conditionally copies files to a target directory if they
are missing from the target directory or have a different size, time, or
date on the target directory. It preserves the name, read/write mode
(read-only attribute), system and hidden attributes, and modification
date and time of the files that it copies. It can also copy entire
subdirectory trees as XCOPY /S does or just portions of subdirectory
trees.
========================================================================
Command syntax
========================================================================
ccp [ -flags ] [ -- ] source ... [ ! Xsource ... ] targetdir
The ccp command conditionally copies files whose names match the source
file specification(s). It ignores hidden and system files. It copies
files to the target directory. The target directory must exist.
If there is only one source file specification and no Xsource file
specifications, then the targetdir is optional. In this case, it
defaults to . (a dot, which means the current directory).
A source file specification consists of an optional drive, an optional
path, and a filename. The filename can contain pattern-matching
characters (see the pattern.doc file for a complete description of
patterns in a filename). If a source file specification is a directory,
then ccp appends "\*" to it, matching all files in the directory.
If a ! is specified, then ccp will exclude (not copy) any source file
whose source name matches one of the Xsource patterns (listed between
the ! and the target directory). Each Xsource pattern must match the
full source name to exclude the source file. An Xsource pattern may, of
course, contain drive and path information.
Generally, an Xsource pattern should start with a "*" character or with
the drive and path of a source file (as specified on the command line)
or it will not exclude any source files. This is because ccp compares
each Xsource pattern with the path and name of each source file as it
was specified on the command line, and including any subdirectory names
that ccp added due to the -s flag. See the examples for more details.
Both \ (backslash) and / (forward slash) characters are interpreted as
path separators in source file specifications, the Xsource (exclude
source) patterns, and the target directory specifications. Therefore,
the \ (backslash) character cannot be used as an escape character in an
Xsource pattern.
This program writes the names of source files (both those copied and, if
the x flag is specified, those excluded) to standard output. It writes
all other messages, errors, and copy count statistics to standard error.
========================================================================
Flags
========================================================================
Normally, ccp only copies a source file if it is missing from the target
directory, has a different size on the target directory, or has a
different modification date and time on the target directory.
The behavior of ccp can be altered by one or more flags. All flag
characters must follow the "-" and must be contiguous (no intervening
spaces). The following flag characters are supported:
-l (letter el) If a file with the same name as a source file exists
in the target directory, copy the source file only if its
modification time is later than that of the file in the target
directory. In other words, only copy source files that are
later than those in the target.
-d If the target directory doesn't already exist, create it before
attempting to copy any files to it. The ccp program creates any
path components within the target directory that don't already
exist.
-e If a file with the same name as a source file doesn't exist in
the target directory, then don't copy the source file. In other
words, only copy files that already exist in the target.
-f Force copy even if target file is read-only.
-n Just display the names of source files that would have been
copied, but don't actually copy any files. If the -d flag is
also specified and the target directory doesn't exist, then the
target directory is also not actually created.
The -n flag is an excellent way to see just what files would be
copied and which files would be excluded without actually
copying anything.
-s Descend subdirectories while searching for files to copy, just
as XCOPY /S does. The subdirectory structure (relative to the
source directory) is preserved within the target directory.
When a file is copied, any subdirectories that don't already
exist within the target directory are created by ccp.
If the specified target directory doesn't exist, it is not
created unless the -d flag is also specified. The -s flag by
itself only creates subdirectories within the target directory
but never creates the target directory.
-t For each file copied, show the path and name of each target file
in addition to the path and name of each source file, as
follows:
sourcename -> targetname
-x Also display the names of source files that are being excluded
(not copied). One of the following characters is displayed in
front of each filename that ccp is excluding from copying:
! before files that you want to exclude (via ! Xsource ...).
x before files that ccp decides to exclude (not copy).
-S Also copy system and hidden files.
Since system files are quite often also read-only files, the -S
flag should usually be combined with the -f flag to force
updates. Be very careful when updating system and hidden files!
========================================================================
Examples
========================================================================
ccp a:* .
This command copies all files from the current directory on
drive A to the current directory if they don't exist in the
current directory or have a different size, date, or time in the
current directory.
ccp a:*
This command is the same as the previous one. Since there's only
one file specification, the target directory defaults to the
current directory.
ccp * ! *.cod *xyz* a:
This command conditionally copies all files in the current
directory, except for those whose names end with .cod or contain
xyz, to the current directory on drive A.
ccp -sd c:\windows\* ! c:\windows\temp\* d:\archive\windows
This command conditionally copies the c:\windows directory and
all of its subdirectories to the d:\archive\windows directory,
except for any files that are in the c:\windows\temp directory.
If any path components within the target d:\archive\windows
directory don't exist they are created before copying the files.
ccp -sd c:\windows\* ! *temp* d:\archive\windows
This command works like the previous command except it excludes
any files within c:\windows that contain temp in their name or
in any subdirectory of their name.
ccp -sd c:\windows\* ! *\temp\* d:\archive\windows
This command works like the previous command except it excludes
any files within c:\windows that also have a path component that
includes any "temp" subdirectory.
ccp -sd c:\windows\* ! *\temp\* *sample.c d:\archive\windows
This command works like the previous command except it excludes
any files within c:\windows that also have a path component that
includes any "temp" subdirectory, and it excludes any file named
"sample.c".
Note that the exlusion pattern for sample.c begins with an
asterisk. This ensures that the pattern matches any file ending
in "sample.c" even if there is path or other information present
(such as test.sample.c).
ccp -le * d:\tmp
This command copies all files in the current directory to the
d:\tmp directory that already exist in d:\tmp but have a later
modification date and time than those in d:\tmp.
ccp -n *.exe *.doc a:\
This command displays the names of all of the .exe and .doc
files in the current directory that are missing from the root
directory on drive A or that have a different size, date, or
time in the root directory of drive A. No files are actually
copied.
ccp -nelx * ! *.cod d:\mydir
This command displays the names of files that would have been
copied, but doesn't actually copy anything.
It looks at all files in the current directory, excluding any
that end in ".cod". It displays the names of the source files
(that it would have copied) that exist in the target directory
and that are later than their counterparts in the target
directory.
Since you excluded the *.cod files, ccp displays the names of
the *.cod files with a "!" before each of their names. Since ccp
excludes files that either don't exist in the target directory
or have the same or earlier modification time in the source
directory, ccp displays these latter files with an "x" before
each of their names.
ccp -st c:*.exe d:
This command copies all of the .exe files within the current
directory and all of its subdirectories on drive c: to the
current directory on drive d:. If a subdirectory in which a
copied file doesn't exist in the target, ccp creates it. Note
that ccp creates subdirectories within the target only for files
that are copied.
The -t flag tells ccp to show the path and name of each target
files that is copied as well as its source path and name. For
subdirectory copies, this provides feedback that lets you know
exactly where each source file is being copied.
========================================================================
Miscellaneous Notes
========================================================================
The pattern * matches any filename. The pattern *.* matches any filename
that contains a dot. Note that *.* will not match a filename that
doesn't contain a dot! This is important to remember! See the
pattern.doc file for more details.
The handling of the archive attribute of a copied file varies depending
upon the platform. The DOS version uses a custom open/read/write/close
copy loop and copies all attributes exactly. The Win32 version uses the
native Windows CopyFile() API function and also preserves the archive
attribute. The OS/2 version uses the native OS/2 DosCopy() API function
and always sets the archive attribute bit of the target file even if the
source file's archive attribute is not set.