Windows Batch to Copy Files in an Excluded Set

Dear Experts,

I would like to write a batch script (CMD) to copy files from c:\temp of one Windows machine to a shared folder let's say pshared in another machine. However, the script should copy files with names not starting with B,DE and F. How can I achieve this?

Best Regards
GurcanKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
robocopy should do the trick (part of the OS since Vista/W2k8):
robocopy.exe "C:\Temp" "\\SomeServer\SomeShare" *.* /xf b* d* e* f* /r:0

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GurcanKAuthor Commented:
Anything other than robocopy such as copy or xcopy?
0
oBdACommented:
Not without additional scripting; and robocopy is far better anyway. In Vista, the xcopy help even provided a warning that it's deprecated and robocopy should be used instead.
1
Robberbaron (robr)Commented:
not sure that pure batch can handle this other than copy all, then delete B*,D*,E*,F*.  
this works but is not very efficient
set typ=*.frm
set src=c:\ee
set dest=c:\ee\done
xcopy /C %Src%\%typ% %dest%
del /q %dest%\B*.*
del /q %dest%\E*.*
del /q %dest%\F*.*
del /q %dest%\G*.*

Open in new window


 
is vbscript ok ??
set typ=*.*
set src=c:\temp
set dest=\\zeus\phared
xcopy /C %Src%\%typ% %dest%
del /q %dest%\B*.*
del /q %dest%\E*.*
del /q %dest%\F*.*
del /q %dest%\G*.*

Open in new window

1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.