复制文件夹及其所有子文件夹和文件(类似于 xcopy).
FileCopyDir, Source, Dest [, Flag]
参数
-
Source
-
源目录的名称 (不含末尾的反斜线), 如果未指定绝对路径则假定在 %A_WorkingDir% 中. 例如: C:\My Folder
Dest
-
目标目录的名称 (不含末尾的反斜线), 如果未指定绝对路径则假定在 %A_WorkingDir% 中. 例如: C:\Copy of My Folder
Flag
-
(可选参数) 此标志决定了是否覆盖现有的文件:
0 (默认): 不覆盖现有的文件. 如果存在 Dest 名称的文件或目录, 则操作会失败而且不会产生效果.
1: 覆盖现在的文件. 但是,不会删除在 Dest 中没有被 Source 目录中文件覆盖的其他子目录或文件.
此参数可以为 表达式, 甚至是计算结果为真或假的表达式 (因为真和假内部分别保存为 1 和 0).
实例:
FileCopyDir, C:\My Folder, C:\Copy of My Folder ; 示例 #2: 提示您复制文件夹的可运行脚本. FileSelectFolder, SourceFolder, , 3, Select the folder to copy if SourceFolder = return ; 否则继续. FileSelectFolder, TargetFolder, , 3, Select the folder IN WHICH to create the duplicate folder. if TargetFolder = return ; 否则继续. MsgBox, 4, , A copy of the folder "%SourceFolder%" will be put into "%TargetFolder%". Continue? IfMsgBox, No return SplitPath, SourceFolder, SourceFolderName ; 仅从它的完整路径中提取文件夹名称. FileCopyDir, %SourceFolder%, %TargetFolder%\%SourceFolderName% if ErrorLevel MsgBox The folder could not be copied, perhaps because a folder of that name already exists in "%TargetFolder%". return