Dado
Dado

Reputation: 1026

Batch file: Copy all files and folder except one folder

I made a .bat file to copy some files, like backup and i need to copy all except one folder. I have, for example, folder test, and subfolders bin, log, Account... and some more files and i want to copy all files and folders except folder "log".

This is my code for copy all:

if not exist "C:\inetpub\wwwroot\backup\test" xcopy "C:\inetpub\wwwroot\test" "C:\inetpub\wwwroot\backup\test" /s /i

Upvotes: 4

Views: 4315

Answers (1)

Alex K.
Alex K.

Reputation: 175766

Use the robocopy command instead, it has /XD to exclude directories by name.

robocopy "C:\inetpub\wwwroot\test" "C:\inetpub\wwwroot\backup\test" *.* /XD "log" /S

Upvotes: 6

Related Questions