批處理指令碼 - 複製



此批處理命令用於將檔案從一個位置複製到另一個位置。

語法

Copy [source] [destination]

將從源位置複製檔案到目標位置。

示例

以下示例顯示了 copy 命令的不同變體。

@echo off
cd
Rem Copies lists.txt to the present working directory.
If there is no destination identified , it defaults to the present working directory.
copy c:\lists.txt
Rem The file lists.txt will be copied from C:\ to C:\tp location
copy C:\lists.txt c:\tp
Rem Quotation marks are required if the file name contains spaces
copy “C:\My File.txt”
Rem Copies all the files in F drive which have the txt file extension to the
current working directory copy
F:\*.txt
Rem Copies all files from dirA to dirB. Note that directories nested in dirA will not be copied
copy C:\dirA dirB

輸出

所有操作均按批處理檔案中的備註執行。

batch_script_commands.htm
廣告