Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 969
  • Last Modified:

XCOPY Syntax? Flatten Tree Structure.

Okay, all you old school DOS hackers, here's one that I've never thought about before..  

I've got a tree of files..  ie.  Folder1\Font1.ttf, Folder2\Font2.ttf

I want to "collapse" all the files in all those sub-folders into ONE folder.

IE, I end up with \FinalFolder\Font1.ttf and \FinalFolder\Font2.ttf.

I Canna figure any syntax (easily) to do that.

Suggestions are appreciated!

-- Scott.

  • 2
1 Solution
Since you don't say what Folder1 and Folder2's parent folder is, I'll not only call it a directory, but I'll name it "Folder" and presume you want to get the files there, too.

for /f "tokens=*" %i in ('dir/s/b/a-d path\to\Folder') do copy "%i" "path\to\FinalFolder"

(I'll presume you COPY rather than MOVE, to prevent accidents....)

...Of course, add "\*.ttf" to path\to\Folder to select files "*.ttf"

scdavisAuthor Commented:
Thanks, Bill.

Worked like a charm.

Most of the syntax I'm familiar with ..  excluding the variable passing.

If you have time, please contact me via email direct (scott DOT davis AT beanfield.com).

I'm really curious where you learned those variable handlers.

certainly ain't in the dir /? "man page".

My Sincere thanks,



Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now