NAME
BackupIfExists — Make a backup if the file exists.
SYNOPSIS
BackupIfExists FilePathValue ?Extension?
DESCRIPTION
Return Value
1 Did do a backup.
0 Did not do a backup.
Arguments
FilePathValueFile path for the original file.
ExtensionOptional. Name of the extension the backup version should get. Defaults to bak.
More Info
This command will check to see if the file exists and if so, create a copy ending with .bak (or any other extension).

This command is meant to be paired with RestoreIfExists to make for a very primitive, "one version only" backup mechanism to use with applications.


For information regarding exceptions / errors, see here.
EXAMPLES
% String2File "testing 1 2 3" test.txt
% cat test.txt
testing 1 2 3
% BackupIfExists test.txt
Copying test.txt to test.txt.bak
1 file(s) copied.
% cat test.txt.bak
testing 1 2 3
SEE ALSO
RestoreIfExists, file
KEYWORDS
file