Batch file to copy folders & files except few

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
anupam
Posts: 1
Joined: 12 Jul 2018 07:01

Batch file to copy folders & files except few

#1 Post by anupam » 12 Jul 2018 07:10

Hello All Expert,

Looking for a batch file which should copy all folders & files except few to another named folder .

Lets say I have folder1 having 3 folders A , B , C and 2 file1 , file2 where each folder A, B and C has some more files & folders.

So I need to copy entire content of A , B and File1 to another folder leaving folder C and file2.

Could someone please advise Many thanks.

pieh-ejdsch
Posts: 240
Joined: 04 Mar 2014 11:14
Location: germany

Re: Batch file to copy folders & files except few

#2 Post by pieh-ejdsch » 13 Jul 2018 06:58

Hello anupam,
With xCopy /s folder1\file1 destination /exclude:list.txt
.. you can give a list with excluded paths.
See also xCopy /?

Phil

SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Re: Batch file to copy folders & files except few

#3 Post by SIMMS7400 » 13 Jul 2018 07:56

Pieh's suggestion is great because it's cleaner as you can include your exclusions in a file. but this also works if you dont have many:

Code: Select all

ROBOCOPY /E  "%SOURCE%" "%TARGET%" /XD Logs Errors Files /XF *.log *.err *.txt

Post Reply