i have text file that contains eg:
c:\test\test1.txt;d:\test2\j.js;d:test2\2.cs
I need to copy those files that are delimited using windows command line bat file to given folder that is passed to bat f开发者_开发技巧ile. How can I achieve this?
Very easy, actually:
for /f %%l in (somefile.txt) do (
for %%f in (%%l) do (
copy "%%f" %1
)
)
The first loop iterates line-wise over the file; the second one will split at semicolons (and other things, e.g. spaces and commas). If the file names look like those you provided it should work.
If the copy destination(s) looks like that too, just add two more loops, obviously:
for /f %%l in (somefile.txt) do (
for %%f in (%%l) do (
for /f %%k in (destination.txt) do (
for %%g in (%%k) do (
copy "%%f" %%g
)
)
)
)
You can copy files from file list with the following batch-file command:
for /f "usebackq delims=;" %%f in (filelist.txt) do copy %%f %1
Assuming filelist.txt has each file name on a separate line:
c:\test\test1.txt;
d:\test2\j.js;
d:\test2\2.cs
No idea how to parse single line though.
精彩评论