开发者

copy list of files whose paths are in semi colon delimited source.txt file to destination folder keeping their souce paths

i have list of files in test.txt which contains list of file paths in format d:\source\www\default.aspx;d:\source\common\common.js I need to write a bat file to copy these files to destination eg.F:\destin开发者_StackOverflowation\ whose path is also passed as an parameter to the bat file.I have following script for this for /f %%l in (somefile.txt) do ( for %%f in (%%l) do ( copy "%%f" %1 ) ) issue is i need to keep the copy source folder's folder structure in destination folder too. ie above d:\source\www\default.aspx need to copy to f:\destination\www\default.aspx not to f:\destination. Will gratefull if some one can give solution to this.


Please try with xcopy /I "%%f" "%~1\%%~pf":

  • xcopy will create the directory structure for you (without prompting because of the /I switch);
  • %%~pf is the path-only part of the file to copy (see help for), appended to your destination base path without any surrounding quotes %~1;
  • the destination path combination is enclosed in quotes.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜