Flatten Folder Structure
Puts every file from a folder tree into a single folder, renaming files whose names clash, either as copies in the run folder or by moving the files in place.
Flatten Folder Structure takes a folder with any number of sub-folders and gathers all of the files into one folder. By default it writes verified copies to the run's files folder and leaves the input untouched. With Change files in place on, it moves the files up into the top of the input folder itself, and logs every move.
All names are planned before anything is copied or moved, in natural folder order (F2 before F10). The first file in that order keeps its name; later files with the same name are renamed by number or by folder prefix. Files already at the top level always keep their names. The same input with the same settings always gives the same names.
Use it when
- A collection or export arrives in deep nested folders and the next step (a review platform, a processing tool or a person) needs all the files in one place.
- You want a flat working copy of a set of documents while keeping the original structure intact.
- You need to pull files out of sub-folders in place and want a complete record of where each file came from.
How to run it
- Choose the top folder as Input. Leave recurse on, otherwise there is nothing below the top level to flatten.
- Choose an Output folder outside the input folder. The report goes there even for an in-place run.
- If only some file types should be gathered, list them in extensions (for example
.pdf, .msg). Empty means every file. - Choose collisions:
NumberorFolderPrefix. - Leave Change files in place off to get copies. Turn it on only if the input itself must be changed; you will be asked to confirm.
- Click Run, read the notes, then click Open report.
Settings
Every setting has the same help beside it in the app. On the command line, pass each as --name value; ltk help flatten-folders lists them.
Settings
| Setting | What it does | Type and default |
|---|---|---|
Collisions--collisions |
When two files have the same name: Number (name_(1).ext, name_(2).ext…) or FolderPrefix (the folder path is added in front: Sub\Folder\name.ext becomes Sub_Folder_name.ext). The first file in folder order keeps its name. Only files whose name is already taken are renamed; every other file keeps its name. Number gives report_(1).pdf, report_(2).pdf. FolderPrefix gives names such as Sub_Folder_report.pdf, which show where the file came from; if that name is also taken a number is added as well. |
choice: Number, FolderPrefixNumber |
Remove empty folders--remove-empty-folders |
In-place only: remove sub-folders that this run empties by moving their files out. Folders that were already empty, and hidden or system folders, are kept. Each removed folder is listed in the report with its original dates. Off by default. Has an effect only with Change files in place on. A folder is removed only if this run moved files out of it and it is empty afterwards. Folders that were already empty, folders that still hold files not selected by extensions, and hidden or system folders are kept. Each removed folder gets its own report row recording its original created and modified times (UTC). |
yes/nofalse |
Common settings
| Setting | What it does | Type and default |
|---|---|---|
Input required--input |
Folder (or single file) to read. It is opened read-only and never modified. | folder empty |
Output required--output |
Folder for reports. Must not be inside the input folder. Each run gets its own sub-folder. | folder empty |
Change files in place--in-place |
Off (default): changed copies are written to the output folder and the input is untouched. On: files in the input folder itself are renamed/moved, and every change is logged in the report. You will be asked to confirm. Files are moved to the top of the input folder. Nothing is ever overwritten: a name that already exists there counts as taken. Empty sub-folders are left behind unless remove-empty-folders is on. |
yes/nofalse |
Recurse--recurse |
Include sub-folders. | yes/notrue |
Extensions--extensions |
Only process these extensions (e.g. .pdf, .docx). Empty means the tool's default set. Files of other types are not touched, not copied and not listed in the report. |
list empty |
Parallelism--parallelism |
Files processed at once. Use 1-2 for spinning disks or network shares. | number4 |
What you get
Each run creates its own folder inside the output folder, with the report flatten-folders.csv, errors.csv and manifest.json (see Run folders and manifests).
files\…: Copy mode only: every selected file in one folder, with its original timestamps. Each copy is verified as it is written.flatten-folders.csv: One row per file (and per removed folder): OldPath, NewPath, NewName, Renamed (True when the name changed), Action, Status, MD5 and Message.in-place-journal.csv: In-place runs only: each change written to disk before and after it is made, so the state can be checked even if a run is interrupted.errors.csv: Files that could not be copied or moved, with the reason.
Report columns
RelativePathOldPathNewPathNewNameRenamedActionStatusMD5Message
Check the result
- Read the notes: they say how many files were renamed because of a clash, and for an in-place run how many were moved and how many failed.
- Filter the report on Renamed = True to see every file that now has a different name.
- Check
errors.csv. A failed file is left where it was. - After an in-place run that was cancelled or stopped, the notes say the input was partly changed; the report and journal list every move that was made.
- Use copy mode unless there is a good reason not to. It leaves the original structure as evidence of how the data was received.
- The report's OldPath and NewPath columns give the original location of every file, so the folder structure can be reconstructed or recorded in a load file.
FolderPrefixis useful when folder names carry meaning, such as custodian or mailbox folder names.
- In place changes the input folder. Do not run it on original evidence; work on a copy. The run asks for confirmation, and from the command line it needs
--confirm-in-place. - When files move to a different drive in place, they are copied with their attributes and timestamps and verified, but Windows permissions are not carried across. The notes say when this happened.
From the command line
The command line is part of LitTechKit Pro. See Command line.
ltk run flatten-folders --input "D:\Matter\Collection\Custodian A" --output "D:\Matter\Work" --collisions FolderPrefix
Related tools
- Copy Folder: Copies a whole folder tree (including empty folders) to the output with hash verification of every file, preserved timestamps, multi-threaded copying and automatic retries. Replaces Robocopy.
- Rename Files: Renames files with find/replace (text or regex), prefix and suffix rules, or an old name → new name list. Copies to the output folder by default, or renames in place with a full change log.
- File Inventory: Lists every file with size, timestamps, attributes, hashes and detected file type, flagging extensions that don't match the content.
- Deduplicate: Finds duplicate files by hash (and duplicate emails by their content), globally or per custodian. Reports every file as Unique, Master or Duplicate, and can copy out one copy of each.