Can I copy multiple named files on the Windows command line using a single “copy” command?

前端 未结 3 2106
名媛妹妹
名媛妹妹 2021-01-31 15:37

I\'d like to copy several known files to another directory as a part of a post-build event, but don\'t want to have lines and lines of \"copy [file] [destination] [switches]\" i

相关标签:
3条回答
  • 2021-01-31 15:44

    You can use 'for' either in a batch file or directly from the command prompt:

    for %I in (file1.txt file2.txt file3.txt) do copy %I c:\somedir\
    

    Wildcards are supported in the filelist as well:

    for %I in (*.txt *.doc *.html) do copy %I c:\somedir\
    

    For more info, just type for /? from a command prompt, or for a much easier to read help use Start->Help and Support and search for "For". On my XP Pro box, it was item 15 in the full text search results.

    0 讨论(0)
  • 2021-01-31 15:44

    Use the <Copy> MSBuild task.

    0 讨论(0)
  • 2021-01-31 16:00

    XP and Vista replaced xcopy with robocopy, and it will do exactly what you want. The syntax for what you want feels backwards at first, but it does the job:

    robocopy source\folder a\dest\folder file1.exe file2.bat file3.dll file4.txt
    
    0 讨论(0)
提交回复
热议问题