Copy a file appending a number to make the to name unique, with
default to = from.
Usage
file.copy2(from, to)
Arguments
from
character: name of a file to be copied
to
character: name of copy. Default = from with an integer
appended to the name.
Value
logical: TRUE (with a name = name of the file created); FALSE if no
file created.
Details
1. length(from) != 1: Error: Only one file can be copied.
2. file.exists(from)? If no, If no, return FALSE.
3. if(missing(to))to <- from; else if(length(to)!=1) error.
4. file.exists(to)? If yes, Dir <- dir(dirname(to)), find all
Dir starting with to, and find the smallest integer to
append to make a unique to name.
5. file.copy(from, to)
6. Return TRUE.