www.cryer.co.uk
Brian Cryer's Web Resources

CryCopy: Examples of use

CryCopy, a free and simple to use command line file copy tool which supports FTP.

Examples of use:


Publish a website to an FTP server

For most people the GUI tool Web Site Publisher provides an easier method of publishing a website.

Other than the username and password, the following is the script that was once used to update the www.cryer.co.uk website:

CryCopy "C:\Users\Brian\Web\Home Page" ftp:\\www.cryer.co.uk\public_html /u:myusername /p:mypassword /v1 /subs /delete /Errors:C:\Temp\PubCryerErr.log

(The above should be on one line, it may wrap in the browser.) What this done is:

"C:\Users\Brian\Web\Home Page"
This is specifying the folder to copy from. In this case it is a local folder. It is enclosed in quotes because the folder path contains a space. Were it not for the space the quotes would not be needed.
ftp:\\ftp.cryer.co.uk\public_html
The destination to copy to. The "ftp:\\" section at the start shows that it is to be copied to an FTP server. In this case "ftp.cryer.co.uk" is the DSN name for the FTP server, and "public_html" is a folder on the FTP server into which files are to be copied.
/u:myusername
Specifies the username to use with the FTP connection.
/p:mypassword
Specifies the password to use with the FTP connection. If no password is specified then the password is taken to be empty, the tool will not prompt for a password.
/v1
Gives a status output (on the command line) of the number of files copied, and remaining to be copied. Also lists files as they are copied.
/subs
Consider subdirectories. Without this only the contents of the source folder will be copied and not any sub-directories.
/delete
Delete old files. Without this flag new and modified files will be copied to the FTP server but any files that have been removed in the source folder would not be removed at the server.
/Errors:C:\Temp\PubCryerErr.log
The name of file to log any errors to. Any errors will also appear on the standard-output, but using this allows errors to be captured to a separate log file.

Top


To download from an FTP site

The following script used to be used (on a weekly basis) to download virus definitions from the network associates FTP site:

CryCopy ^
    ftp:\\ftp.nai.com\pub\antivirus\datfiles\4.x ^
    C:\Active\Virus\Defs                         ^
    /user:anonymous                              ^
    /V1                                          ^
    /Log:Update.log                              ^
    /DeleteOld

Top


Backup a set of files from a local folder to a network share

CryCopy /subs /readonly /newer /Make /V1 /deleteold ^
    "C:\Brian\Other Notes"                          ^
    "\\kserv\Brian\Active.OtherNotes"               ^
    -*.tmp                                          ^
    -*.bak                                          ^
    -*.wbk


This copies everything except .tmp, .bak and .wbk files from the local folder to a network share. It does not copy sub-directories, because the "/s" flag has not been specified.

Note:

Top


To copy a single specific file from one folder to another

To copy a single specific file from one folder to another:

CryCopy "C:\Brian\Other Notes" "C:\Temp" +\file.doc

Normally "+" is used to specify a wildcard expression, such as "+*.doc". In this case there is no wildcard, so the file will only be copied if it matches against the full path. The starting directory, in this case "C:\Brian\Other Notes" is not included when performing the wildcard match, so "\file.doc" means only a file called "file.doc" in the top most folder considered, which in this case is "C:\Brian\Other Notes\file.doc".

Top


Copy to an FTP server using a-non standard control port

To use an FTP port other than the default (control) port of 21, append :port-number to the server address. So for example, to use port 20 instead of the default port 21:

CryCopy "c:\users\brian\web\home page" ftp:\\upload.ntlworld.com:20 /U:username /P:password /V1 /delete /subs /errors:C:\Temp\PubNtlErr.log

Do not specify a port unless you have good reason for doing so, as in most cases this will stop it from working.

Note:

  1. Whilst these examples are copying to an FTP site, it can be used locally to copy from drives or network shares.
  2.  Other than a source and destination, all other parameters are optional.
    If you provide a spec of files to copy, e.g. "+*.htm", then ONLY those files that match will be copied. If you don't specify any files to include in the copy then all files will be copied.
  3. The + and - file specs are matched against the full path name not just the filename, so "-*\foo\*.tmp" will ignore any tmp files under "\foo" (or \foo\example\ etc).
    To specify to ignore a folder add a trailing backslash, so "-*\foo\" will ignore all directories called "foo".
  4. You cannot (currently) use a trailing backslash to specify to include only matching folders.

Top