Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcopy wildcard source folder name to destination

I want to copy from a wildcard source folder to a destination folder:

xcopy a:\parentfolder\n* x:\parentfolder

Only folders starting with "n" should therefore be copied to the destination.

Any help to get this working would be much appreciated.

like image 470
Wonderer Avatar asked Apr 22 '14 02:04

Wonderer


2 Answers

for /f "delims=" %%a in ('dir /b/ad "a:\parentfolder\n*" ') do xcopy "a:\parentfolder\%%a\*" x:\parentfolder\

As you have it, XCOPY assumes that n* is a filespec, and there's no way to tell it otherwise.

like image 183
Magoo Avatar answered Oct 19 '22 16:10

Magoo


If you first CD to the folder you want to copy it will work:

a:
cd \parentfolder
xcopy /s n*.* x:\parentfolder
like image 43
Raul Suarez Avatar answered Oct 19 '22 15:10

Raul Suarez