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 (seehelp for
), appended to your destination base path without any surrounding quotes%~1
;- the destination path combination is enclosed in quotes.
精彩评论