Exclude folders in batch-copy-script

前端 未结 2 1662
予麋鹿
予麋鹿 2021-02-08 23:20

I am using a batch file on a USB stick to backup my pictures. I use the following command:

for /r C:\\ %%x in (*.jpg *.png *.gif) do @copy /y %%x .
2条回答
  •  别那么骄傲
    2021-02-09 00:08

    Drop COPY and use ROBOCOPY which exists in Windows Vista+ & is downloadable for prior versions.

    It supports /XD to exclude specific directories & /XF to exclude file masks at the command line.

    E.g.

    robocopy.exe c:\ c:\destination\ *.jpg *.png *.gif /xd "Program files" "windows" /S
    

    (Note this will recreate the directory structure in c:\destination\, which thinking about it may not be what you want)

提交回复
热议问题