REFERENCE
U.COPY_FILE
Summary
Copies file(s) from to specified destination, optionally renaming or zipping/unzipping in the process
Syntax
=U.COPY_FILE(source, target_directory, [target_filename], [overwrite], [flip_zip], [delete_source], [block])
Parameters
| Parameter | Required | Description |
|---|---|---|
source |
Yes | The file or directory to be copied. Filenames can have wildcards (* and/or ?) and matching files will be copied. Pass filename(s) as pipe-delimited right cell in 2-column range to have all subdirectories searched. If no full path then directory of current workbook is searched for specified file(s) |
target_directory |
Yes | The directory to which source file(s) will be copied. Directory of source file used if not provided here or within target filename. To have all source files copied to top level of target, pass as 2 cells with right cell set to TRUE |
[target_filename] |
No | The new filename to be given to copied file. If a full path provided then path is ignored if target directory provided in 2nd parameter. If ends in ".zip" and flip_zip is TRUE then all source files are copied into single zip. If ends in ".gz" and flip_zip is TRUE then gzip compression is used |
[overwrite] |
No | Set to TRUE to overwrite the target file(s) that may already exist. Include a 2nd column also set to TRUE to entirely replace a directory. Include a 3rd column set to TRUE to have files permanently deleted instead of sent to the recycle bin. By default the copy is aborted if specified target file already exists. |
[flip_zip] |
No | Set to TRUE to have compressed files extracted and vice-versa during copy. Set to "zip" to have all source files placed in a single zip file. Set to "gz" to have gzip compression used on individual files |
[delete_source] |
No | If set to TRUE then source files are deleted after a successful copy. When copying and deleting all files in a directory and subdirectory, provide a 2nd value of FALSE to prevent deletion of the source directory structure. Provide a 3rd value of TRUE to delete the source permanently instead of sending to the recycle bin. |
[block] |
No | If set to TRUE then method will not be calculated unless triggered by user interaction or calculated as a step in a script; If set to a number then will be throttled to not calculate more frequently than the specified number of seconds; make number negative to prevent auto recalc of blocked methods |
Behavior
The documented public interface is supported by the current U Add-in source signature and the maintained Usage Examples workbook. Optional parameters are shown in square brackets in the syntax above; omit the brackets when entering a formula.
Return Value
Returns the function result or action status described by the formula and parameters above. The maintained sources do not define a narrower, stable return contract for this function.
Examples
Notes
- Formula examples are preserved from maintained workbook usage and normalized to the current
U.prefix. - Complete formulas demonstrate working patterns; they do not imply that undocumented option values are supported.
- Where maintained sources do not specify every accepted value, default, or error message, this page does not infer one.
- For functions that perform actions, use a visible trigger or supported block/throttle parameter to avoid unintended repetition during recalculation.
Related
- How-to: Process CSV Files
- Example: CSV Processing Pipeline
- Concept: Caching and Throttling