xcopy wildcard source folder name to destination

旧巷老猫 提交于 2019-11-28 01:14:29

问题


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.


回答1:


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.




回答2:


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

a:
cd \parentfolder
xcopy /s n*.* x:\parentfolder


来源:https://stackoverflow.com/questions/23209474/xcopy-wildcard-source-folder-name-to-destination

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!