XCOPY directories starting with certain letter

I'm trying to copy directories and their contents to another directory.  The catch is that I want only the directories that start with the letter B to transfer, then be deleted.  My batch file looks like this:

xcopy "C:\Documents and Settings\Mike\My Documents\My Music\Local Test\B*" Z:\Music\Albums\Test\*.* /e /d /r /y
del "C:\Documents and Settings\Mike\My Documents\My Music\Local Test\B*" /q

I've been trying different things and just can't seem to get it.  Any thoughts?

Also, can anyone recommend a good site to reference for batch file creation?  I'm not even sure what all the parameters at the end mean, which could be one of my problems.

Thanks in advance.
russomrAsked:
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.

GuruGaryCommented:
For the batch file, try this:
@echo off
setlocal
set source=C:\Documents and Settings\Mike\My Documents\My Music\Local Test
set dest=Z:\Music\Albums\Test
set prefix=B

for /f "tokens=*" %%a in ('dir /b "%source%\%prefix%*"') do (echo Moving "%%a"
   xcopy "%source%\%%a\*.*" "%dest%\%%a\" /s /h /k /c /y
   rd "%source%\%%a" /q /s)

echo Done.


Just modify the 3 SET lines at the top if you want to make changes to the Source, Destination, or the Directories "start" letter.

For batch file reference ... you can try http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx from Microsoft.  You can get syntax on most commands with the /? parameter ... like:
XCOPY /?

The xcopy switches I used are:
/s = get subdirectories
/h = get hidden and system files also (since we are going to be deleting the directories we should get everything)
/k = keep attributes of files
/c = continue on error
/y = yes, copy files without prompting
0

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
russomrAuthor Commented:
Perfect.  Thank you.
0
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
Microsoft DOS

From novice to tech pro — start learning today.