Examples

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

    Also notice that forward slashes work just as well as backslashes. Indeed, when running ccp (or any of these other commands) from within a Perl, Python, bash, gawk, or awk script, or from within another scripting language, a backslash is often used to start an escape sequence and a forward slash is a more convenient and robust path separator.

  6. 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.

  7. 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 exclusion 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 and tempdir/sample.c).

  8. 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.

  9. 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.

  10. 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.

  11. 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.

  12. 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.

  13. 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.

  14. 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.

  15. 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 then ccp creates them before copying the files.

  16. 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.

  17. 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.

  18. 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.

  19. 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.

  20. 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.

  21. 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.

  22. 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.