/goflatten

A very small utility that moves all files contained in subdirectories into a defined root directory.

Primary LanguageGoMIT LicenseMIT

goflatten

Go Report Card Go Doc Build status

goflatten is a utility that flattens a nested directory of files into a flat one.

For example, suppose that you have this structure:

pricelist
  -> 2019-01-01
    -> 2019-01-01.csv
  -> 2019-01-02
    -> 2019-01-02.csv

After running goflatten the resulting structure is:

pricelist
  -> 2019-01-01.csv
  -> 2019-01-02.csv
  -> 2019-01-01
  -> 2019-01-02

Installing and running

To install goflatten run:

go get -u github.com/ShiraazMoollatjie/goflatten

Thereafter, you can simply run:

goflatten

Flags

The following flags exist for goflatten:

  • dryRun - If set to false, goflatten will physically move nested files to the root directory. This is set to true by default.

  • rootDir - Specifies the starting root directory. By default, the current working directory is the starting directory.

  • skipDupes - If set to true, duplicate files will not be overwritten when moving them to the root directory. By default, this is set to true.