batch file copy only if numbers match

Microsoft Windows xp professional w/serv...
May 14, 2010 at 05:04:05
Specs: DOS
I have searched the internet and have found nothing. I am trying to copy a file when there are duplicate numbers in each filename. For example in a folder there are many files, when there is blah_blah_7205678.doc and file blah_blah_7205678_blah.xls file I am trying to get the batch file to go through the folder and find the 7 digit matching numbers and store all the matching number files in a new folder. I am having trouble finding out how to copy the matching number in the filenames then copy both files to a folder. I have only found out how to copy filnames that are completely matching so this is a little different. Thanks in Advance!

See More: batch file copy only if numbers match

Report •

May 14, 2010 at 12:54:12
can't this work?
for /f "tokens=*" %%a in ('dir /s /b *7205678*.*') copy %%a .\backup

or possibly even:
xcopy /s *7205678*.* .\backup

Report •
Related Solutions

Ask Question