| Crates.io | rflatten |
| lib.rs | rflatten |
| version | 0.2.1 |
| created_at | 2025-11-06 02:30:27.862592+00 |
| updated_at | 2025-11-07 02:17:55.767258+00 |
| description | Flatten subdirectories by moving all files to the root directory |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1918985 |
| size | 83,654 |
cargo install rflatten
RFLATTEN(1) User Commands RFLATTEN(1)
NAME
rflatten - flatten subdirectories by moving all files to the root
directory
SYNOPSIS
rflatten [OPTIONS] <DIRECTORY>
DESCRIPTION
rflatten recursively moves all files from subdirectories to the root
directory, effectively flattening the directory structure. Files
already in the root directory are not moved. Empty subdirectories are
removed after flattening.
If filename conflicts occur, files are automatically renamed with a
numeric suffix (e.g., file_1.txt, file_2.txt).
OPTIONS
<DIRECTORY>
Directory to flatten (required)
-n, --depth <MAX_DEPTH>
Maximum depth to traverse. By default, all subdirectory levels
are processed. Use this to limit how deep into the directory
structure the tool will traverse.
-y, --yes
Skip confirmation prompt and proceed immediately with the
flatten operation.
-q, --quiet
Quiet mode - suppress all output except errors. Confirmation
prompt is automatically skipped (same behavior as --yes).
-i, --include <INCLUDE>
Include only directories that begin with any of these values.
Accepts comma-separated values. Uses case-insensitive prefix
matching. Cannot be used together with --exclude.
-e, --exclude <EXCLUDE>
Exclude only directories that begin with any of these values.
Accepts comma-separated values. Uses case-insensitive prefix
matching. Cannot be used together with --include.
-h, --help
Print help information
-V, --version
Print version information
EXAMPLES
Basic usage:
rflatten /path/to/directory
Skip confirmation prompt:
rflatten -y /path/to/directory
Quiet mode (no output except errors):
rflatten -q /path/to/directory
Only flatten first level subdirectories:
rflatten --depth 1 /path/to/directory
Flatten up to 2 levels deep:
rflatten -n 2 /path/to/directory
Only flatten the "src" directory:
rflatten --include src /path/to/directory
Flatten multiple specific directories:
rflatten -i src,tests /path/to/directory
Fuzzy match (flatten both "docs" and "documentation"):
rflatten --include doc /path/to/directory
Exclude the "src" directory:
rflatten --exclude src /path/to/directory
Exclude multiple directories:
rflatten -e src,tests /path/to/directory
Combined options:
rflatten -n 2 -e tests -y /path/to/directory
PATTERN MATCHING
The --include and --exclude options use case-insensitive
(prefix) matching. For example:
• "doc" matches "docs", "documentation", "DOCS", etc.
• "test" matches "tests", "testing", "test_files", etc.
Patterns are matched against top-level directory names only.
EXIT STATUS
0 Successful operation
1 Error occurred (invalid directory, permission denied, etc.)
AUTHOR
Written by Andrew Nissen
rflatten 0.1.0 2025-11-05 RFLATTEN(1)