Files

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.

Free Command line: flatten-folders Version 1.0

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

How to run it

  1. Choose the top folder as Input. Leave recurse on, otherwise there is nothing below the top level to flatten.
  2. Choose an Output folder outside the input folder. The report goes there even for an in-place run.
  3. If only some file types should be gathered, list them in extensions (for example .pdf, .msg). Empty means every file.
  4. Choose collisions: Number or FolderPrefix.
  5. 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.
  6. 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

SettingWhat it doesType 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, FolderPrefix
Number
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/no
false

Common settings

SettingWhat it doesType 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/no
false
Recurse
--recurse
Include sub-folders. yes/no
true
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. number
4

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).

Report columns

Check the result

Tips
  • 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.
  • FolderPrefix is useful when folder names carry meaning, such as custodian or mailbox folder names.
Watch out for
  • 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