8

I'm trying to move only a certain type of files, *.txt, from their current location to another folder. I know that can be done in Windows Explorer with the search feature + drag and drop. However, that flattens the folder structure and all files end up in the target folder. What I would like to do is move all those files but preserve their relative folder structure. So given a source that looks like this:

\Source\One\Test1.txt
\Source\One\Test2.avi
\Source\Two\Test3.txt
\Source\Two\Test4.avi

And the destination folder:

\Destination

I'd like a simple way to move or copy the txt files to attain the following:

\Destination\One\Test1.txt
\Destination\Two\Test3.txt
Dave M
  • 13,250

3 Answers3

16

You can accomplish this using the Robocopy utility. Robocopy is standard in Windows Vista, Windows 7 and Windows Server 2008. If you have a previous version of Windows, you can get it as part of the Windows Resource Kit for your version of Windows. From a command prompt, use the following command and it should take care of your problem:

robocopy c:\source c:\destination /E *.txt

More information about Robocopy

Blackwood
  • 3,184
0

Is xcopy available?

xcopy c:\*.bat z:\targetdir /s

Works on XP. I don't have Windows 7 available at the moment, but it should work.

b w
  • 2,784
0

In regards to if xcopy is still available, yes it is in both Windows 7 and Windows 8.1. Not sure about Windows 10. I just used it to move a whole bunch of ISO files to one directory. Use xcopy /? from a command prompt to get a list of available Xcopy commands.