---
title: "Copy-Files"
---
Copies files on a server.
Copy-Files(
[Include: <@(text)>],
[Exclude: <@(text)>],
[From: <text>],
To: <text>,
[Verbose: <true/false>],
[Overwrite: <true/false>],
[RenameFrom: <text>],
[RenameTo: <text>],
[RenameRegex: <true/false>]
);
This operation may be prefixed with Files::
, although this is a built-in namespace and isn't really necessary.
Name | Format | Script Usage | Usage Notes |
---|---|---|---|
Include | @(text) | Include | See KB#1119 to learn more about masking syntax. |
Exclude | @(text) | Exclude | See KB#1119 to learn more about masking syntax. |
Source directory | text | From | |
☆ Target directory | text | To | This argument is required. |
Verbose | true/false | Verbose | |
Overwrite target files | true/false | Overwrite | |
Rename from | text | RenameFrom | |
Rename to | text | RenameTo | |
Use regular expression | true/false | RenameRegex |
# copy all files and all subdirectories beneath it to the target,
# and log each individual file that is copied, and overwrite any files
Copy-Files(
From: E:\Source,
To: F:\Target,
Include: **,
Verbose: true,
Overwrite: true
);
# copy a file, renaming it during the copy
Copy-Files(
From: $WorkingDirectory/build,
To: $WorkingDirectory/staging,
Include: HDARS.exe,
Verbose: true,
RenameFrom: .exe,
RenameTo: .$ReleaseNumber.exe
);
# copy files, renaming them to fit the format desired by this application
Copy-Files(
From: vendorData,
To: vendorData2,
Verbose: true,
RenameFrom: "^(?<module>[a-z]+)\.(?<name>.*)\.xml$",
RenameTo: `${name}-`${module}.xml,
RenameRegex: true
);