fn: cpy
[contents]

Contents

Syntax

The syntax for cpy calls is:

f++:  
cpy(sources, target)
cpy sources target

n++:  
@cpy(sources, target)
@cpy sources target

Description

cpy is the copy function, it copies the files and/or directories specified by the sources parameters to the target specified in the trailing parameter. For more than one source the target should be an existing dirctory, for a single source the target can be either an existing directory or a file to copy to.

Note: Paths can be unoquoted, single quoted or double quoted.

Note: You should also be able to use the copy function for the underlying shell as well, typically copy on Windows and cp on other platforms like FreeBSD, Linux, OSX, etc..

Note: Nift will skip to the first non-whitespace (ie. to the first character that is not a space, tab or newline) after a cpy call and inject it to the output file where the call started. If you want to prevent Nift from doing this put a '!' after the call, eg.:

@cpy dir1 dir2;!
@cp(dir1, dir2)!

Options

The following options are available for cpy calls:

option description
b backup files to be replaced
f ensures files have write permission before trying to overwrite them
i prompt when moving files
n do not overwrite existing files
T treat target as a file rather than a directory
u only overwrite files if file to replace is newer
v output which files are being moved and where (verbose)
option description

f++ example

Examples of cpy being used with f++:

cpy("sample.txt", "sample1.txt")
cpy dir1 dir2 dir3
cpy{u} *.txt dir

n++ example

Example of cpy being used with n++:

@cpy("sample.txt", "sample1.txt")
@cpy dir1 dir2 dir3
@cpy{u} *.txt dir

Sponsors