I have a folder containing many other sub-folders. I am trying to write a batch file which will copy some of the folders to another place on my hard disk. I am using xcopy
for this. The folder structure is as shown below:
FolderB1
FolderB2
FolderB22
File1.txt
File2.txt
File3.txt
I have some .txt
files inside FolderB1, along with FolderB2 and FolderB22. I want to copy FolderB2 and FolderB22 and skip .txt
files contained in Folder B1
I tried using /EXCLUDE
: param of xcopy
command, but it is not able to perform this operation. It does not work if I specify the exclusion as \FolderB1\*.txt
or something of this sort.
The number of main folders is not known. It can be anything. Also, there is no fix pattern for names of .txt
files. Have checked this question too, but did not help.
Also, I want to avoid using del
command, since copying all and deleting again would consume time.
Can this be achieved using Robocopy
? Exactly similar question is raised here.
Any pointers would be useful. Thanks in advance.