DEV Community

Maksymilian
Maksymilian

Posted on

File Bucketer, a simple CLI tool to organize files into buckets

Working with large file collections often requires splitting them into smaller chunks. You might be preparing datasets, batching assets for processing, archiving, or migrating data.

File Bucketer is a lightweight command-line tool that automatically distributes files from an input directory into a specified number of buckets, or into buckets with a defined maximum number of files. It supports both copying and moving files.

✨ Features

  • Automatically splits files from any input directory
  • Choose either number of buckets or number of files per bucket
  • Supports copy and move operations
  • Cross-platform binary (Windows, Linux, macOS)
  • Informative terminal output with clear progress messages

πŸ“¦ Installation

  1. Go to the Releases page
  2. Download the .tar or .zip archive containing the binary
  3. Extract it
  4. Run:

Linux/macOS:

./bin/file-bucketer
Enter fullscreen mode Exit fullscreen mode

Windows:

.\bin\file-bucketer.bat
Enter fullscreen mode Exit fullscreen mode

πŸ› οΈ Usage

Linux/macOS:

./bin/file-bucketer <parameters>
Enter fullscreen mode Exit fullscreen mode

Windows:

.\bin\file-bucketer.bat <parameters>
Enter fullscreen mode Exit fullscreen mode

Parameters:

Option Short option Description Type Required
--input -i Input directory String yes
--output -o Output directory. May not exist String yes
--buckets -b Bucket count. Mutually exclusive with --count option. Must be present if --count option is not specified Int yes/no
--count -c Count per bucket. Mutually exclusive with --buckets option. Must be present if --buckets option is not specified Int yes/no
--transferOption -t Transfer type. Value should be one of copy, move. Defaults to copy copy, move no
--help -h Usage info - no

πŸ“ Example

Imagine you want to split the files located in /home/bob/foo into 5 buckets and move them to /home/alice/foo:

./bin/file-bucketer \
  -i /home/bob/foo \
  -o /home/alice/foo \
  -b 5 \
  -t move
Enter fullscreen mode Exit fullscreen mode

Example output:

Got parameters:
    input: '/home/bob/foo'
    output: '/home/alice/foo'
    buckets: '5'
    count: 'calculated'
    transfer option: 'MOVE'
Validating given input directory...
Validate given output directory...
Counting files under the directory...
Found: 10 files.
Preparing 5 buckets with at most 2 elements...
Pouring into the buckets...
Process completed.
Enter fullscreen mode Exit fullscreen mode

Result:

❯ ls /home/alice/foo
bucket_0 bucket_1 bucket_2 bucket_3 bucket_4
Enter fullscreen mode Exit fullscreen mode

πŸš€ Summary

If you need a straightforward utility to split files without writing your own scripts, File Bucketer provides a simple and efficient solution.

The project is fully open-source and available on Codeberg.
Feedback and contributions are welcome. Happy bucketing!

Top comments (0)