FileSystemCopy


New to Analytica 6.0

Requires Analytica Enterprise edition or better.

FileSystemCopy( source, dest, replace, copyLinks )

Copies a file, or recursively copies a folder and its contents.

Note: There are other ways to copy files or folders by using RunConsoleProcess or system COM objects, but these other methods may be unavailable for security reasons when you run your model on the public Analytica Cloud Platform (ACP) server, whereas this one is available and secure on ACP.

Parameters:

  • «source»: A file path to an existing file or folder to be copied. If this is a relative path, it is interpreted relative to the CurrentDataFolder. Wildcards are not accepted. If the «source» is a folder, then the entire contents will be recursively copied.
  • «dest»: Where the file or folder should be copied to. If this is a relative path, it is interpreted relative to the CurrentDataFolder. When copying a folder, suffix «dest» with '\' if you want to copy into «dest» and don't suffix with '\' if you want «dest» to be the final name. See the examples below.
  • «replace»: (optional, default False) Set to True to replace (without asking) if the destination file exists. False to throw an error if a destination file or folder exists.
  • «copyLinks»: (optional, default false): Set to true if you want symbolic links to be copied.

Return value:

The number of files copied or new folders created.

Examples

  • Both «source» and «dest» can be filenames.
    FileSystemCopy( "C:\MyTemplates\blank.xls", "results.xlsx" )
    ==> Copies to your CurrentDataFolder, same as where your model resides unless you've changed it.
  • When «source» is a file and «dest» is an existing folder, it makes a copy with the same filename in the «dest» folder.
    FileSystemCopy( "C:\MyModels\cashFlow.ana", "D:\Backups\Models", replace:true )
    ==> copies to "C:\Backups\Models\cashFlow.ana"
  • When «source» is a folder and «dest» ends with \, then it makes a copy as the same name as «source» inside the «dest» folder.
    FileSystemCopy( "C:\MyModels", "D:\Backups\", replace:true )
    ==> copies the entire folder tree to "D:\Backups\MyModels"
  • When «source» is a folder and «dest» does not end with \, then «dest» is the name of the copied folder.
    FileSystemCopy( "C:\MyModels", "D:\Models2" )
    ==> The folder "D:\Models2" becomes a replica of "C:\MyModels"

Notes

  • Requires Analytica Enterprise edition or better.
  • Can be used (securely) on Analytica Cloud Platform (ACP). You must have read access to the «source» folder and write access to the «dest» folder.

See Also

Comments


You are not allowed to post comments.