WIN2K DOS Batch Program - TechRepublic
General discussion
October 19, 2004 at 01:26 PM
wreeson

WIN2K DOS Batch Program

by wreeson . Updated 21 years, 6 months ago

I am trying create a script to copy files with the same extension out of multiple directories into a single directory.

It looks a little like this..

c:\mydir\dir1\file1.RTA
c:\mydir\dir2\file2.RTA
c:\mydir\dir3\file3.RTA

..into a single directory..

c:\newdir\file1.RTA
c:\newdir\file2.RTA
c:\newdir\file3.RTA

I can’t use XCOPY because it copies the subdirectories, which I don’t want. So far I’ve created a small batch file that pipes the output from..

DIR c:\mydir\*.RTA /S /B > temp.txt

..giving me the full paths of all the files which looks like..

c:\mydir\dir1\file1.RTA
c:\mydir\dir2\file2.RTA
c:\mydir\dir3\file3.RTA

All I need to do is create some kind of a filter to add in COPY before each path in the file and the destination. So the TEMP.BAT file will look like..

COPY c:\mydir\dir1\file1.RTA c:\newdir\
COPY c:\mydir\dir2\file2.RTA c:\newdir\
COPY c:\mydir\dir3\file3.RTA c:\newdir\

But I don’t know how to do that in a DOS environment.

Anyone know how or an easier way to do it?

This discussion is locked

All Comments