Discussion Locked

Basic DOS copy

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a program that creates a complex "subdirectory" structure that changes each day. I am trying to copy the files from each subdirectory to a new directory. When I use the xcopy /s command, I get the subdirectory structure in the new directory. I only want the files.

Any ideas on how to get files without the directories?
thanks

7 replies

by plenpek

Try copying using the file extension. For example
if file is excutable try

drive:\dir\xcopy *.exe /s drive:\dir

where drive is the your drive letter and dir is the name of the directory where you copy files. Good luck

by tom.young

When I do the xcopy c:\test\*.txt /s c:\tom

It copies all of the files and the subdirectory structure. I only want the files.

Source:
c:\test\test1\file1.txt
c:\test\test2\file2.txt
c:\test\test3\file3.txt

Destination:
c:\tom

I run: c:\test\xcopy *.txt /s c:\tom

I get:
c:\tom\test1\file1.txt
c:\tom\test2\file2.txt
c:\tom\test3\file3.txt

I want:
c:\tom\file1.txt
\file2.txt
\file3.txt

by krystal190

Use the "copy" command instead. The "Xcopy" command is used to copy all directories and subdirectors.

by evalega

xcopy includes all subdirectories. You should create a batch file using copy command and not xcopy command.

by stevecottle

Tom,
I know there's a way to fully automate this using multiple batch files and recursive calls, but the simpler approach if you don't have to do this over and over is the "DIR mydir /S /B > C:\TEMP.TXT" command. This creates a "bare" version of the file list. Specify the directory you want to copy files from instead of "mydir". This will create a TEMP.TXT file on the root directory of your C: drive. You then can edit TEMP.TXT to add "COPY " to the beginning and your destination directory to the end of each line. Save it as TEMP.BAT, and execute it from a DOS prompt. I'd need to go back to PC Magazines from 1985, 1986 to come up with the fully automated recursive technique. It's been a long time.
Steve

by davidfranks78

If you are using windows, how about using the search utility (*.). All the found files can be blocked and copied / moved

Regards

This discussion is closed to new replies.