Avatar of GurcanK
GurcanK
 asked on

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
Windows BatchWindows OSMicrosoft Legacy OS

Avatar of undefined
Last Comment
Robberbaron (robr)

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
GurcanK

ASKER
Anything other than robocopy such as copy or xcopy?
oBdA

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.
Robberbaron (robr)

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

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23