I'm trying to get the first (any) 10 files from a deeply nested filestructure. I can use XCOPY source dest /T /E
to build the folder structure, but what I'd like to do is get 10 files from each folder and sub folder and copy those as well.
Is there a tool that will do this for me?
Your question sounds like you want the first 10 files from every subfolder? This ought to do it (not exhaustively tested!):
If it's saved to a batch file named 'first10.cmd', you can use it like this:
First it prepares the destintation folder structure using xcopy, just as in your question. Then we save a list of all folders to a file, and loop over each one. For each folder, we save a list of all files in that folder, and loop over each file. For each file,
:docopy
builds the copy command and executes it.If you only want the first 10 files out of the whole structure, you could use this (heavily borrowed from Owen's answer!)
Use it like:
I'm almost certain you can't do this using a regular xcopy command, you're going to have to use some form of script to find the files you actually want then just pass them to xcopy one by one - that or build one hell of an 'exclude' string :)