fs.copy
fs.copy
Function
Copy files or directories to the target path.
Syntax
fs(path).copy(to)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| to | String | Yes | None | The target file or directory path. |
Return value
| Type | Description |
|---|---|
| Bool | Returns true if the copy is successful. |
Example
file = fs('docs-copy.txt') file.write('BT') result = file.copy('docs-copy-2.txt') // Output: true print result
Notes
- When copying a directory, the directory contents are copied recursively.