简体   繁体   中英

Copying files using Copy in batch script copies only the first file to the destination folder

This is my copy command :

set POLL="C:\Documents and Settings\"
copy Register.class+Ca.class+pack %POLL% /-Y

pack is a folder here.
The result of the above copy coman is that only Register.class gets copied to the destination folder. What's my mistake?

Naming multiple source files for a copy command copies the files into one single file.

copy fileone + filetwo filethree

would result in filethree containing the content of fileone AND filetwo. You cannot copy multiple files to a different location with copy.

However it is fairly easy to do so using either a loop or xcopy-command:

set POLL="C:\Documents and Settings\"
FOR %%F IN (Register.class Ca.class) DO copy %%F %POLL% /-Y
xcopy pack %POLL% /-Y

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM