need files from multi folders into one

Soldato
Joined
18 Oct 2002
Posts
10,383
Location
Behind you... Naked!
I am working on several years worth of data for our club.

We have files that are several folders deep, and I need to be able to somehow get all of the files simply into one folder.

For example... they are mostly sorted out like this :-

\year\month\activity\person\blahblah.txt

Which is good and would have been a great thing, but searching is a hellish nightmare

we are collating a whole load of files into one simply file, so that all of the records of one person, is stored in that one persons folder, no matter what

Anyway, it does not matter what its for, I am trying to pull all of the files back into just the one folder... Anyone have any clues to do it massive match file-ish.

I am working on over 400.000 files you see and doing it manually, has proven to be a bad idea! NOT LOL AT ALL
 
Soldato
Joined
5 Mar 2010
Posts
12,342
If the directory structure is the same, you could mock something up in powershell. Effectively you'd start by getting it to list all items within the first directory, and then move those items into a new directory path.
 
Soldato
Joined
25 Jan 2006
Posts
2,671
Location
Birmingham
If all the file types are the same, you could search the top level folder for that file type .txt. Then copy/paste all the results of the search into a new folder.
 
Last edited:
Associate
Joined
18 Sep 2008
Posts
983
Are there any words in part of the path that remains constant?

If so, you could use the Everything program. In the search box, type in the part of the path and .txt and it will show you all files in all subfolders. You can then select all and move or copy into your one folder.

If you need to automate it, you could use PowerShell command Move-Item or Copy-Item in Example 4.
 
Associate
Joined
21 Dec 2005
Posts
576
Location
Felixstowe
I've written a couple of programs to do something really similar and could easily adapt it for you if you can tell me exactly what you need.

The only caveat is what the club is for, I am a lot less inclined to help if you are left-wing, anti-everything, teetotal, loonies :)
 
Associate
Joined
17 Sep 2008
Posts
1,729
Not sure if I've understood you correctly, but if you just want to suck all the contents of a directory tree back into its base folder, create this batch file (call it "flatten.bat" or something) and run it from a command prompt in the base folder:

Code:
@echo off
for /r %%f in (*) do @move "%%f" .

(note the space and trailing point following the "move" command)

You could replace the (*) wildcard with whatever filetypes you want if you don't want to move absolutely everything back into the base folder.
 
Back
Top Bottom