randselect

Crates.iorandselect
lib.rsrandselect
version0.3.1
sourcesrc
created_at2018-11-25 07:41:29.110897
updated_at2023-07-03 14:36:27.821732
descriptionTool for randomly selecting files from a directory.
homepagehttps://github.com/lukehsiao/randselect
repositoryhttps://github.com/lukehsiao/randselect
max_upload_size
id98559
size48,098
Luke Hsiao (lukehsiao)

documentation

https://docs.rs/randselect

README

randselect

Crates.io GitHub Workflow Status (with event) Crates.io

This crate provides a simple command line utility for randomly selecting N files from a directory and copying or moving them to a target directory.

randselect operates (inefficiently) by generating a random permutation of the files in a given directory, then moving or copying the first N files in the resulting permutation to a target directory.

Could you do this with a few lines of bash? Almost certainly! This was just an excuse to write some Rust.

Install

You can install this with Cargo:

$ cargo install randselect

Usage

randselect
Tool for randomly selecting files from a directory.

USAGE:
    randselect [OPTIONS] <IN_DIR> <OUT_DIR>

ARGS:
    <IN_DIR>     The input directory to select from
    <OUT_DIR>    The directory to output to. Will be created if it doesn't exist

OPTIONS:
    -g, --go                       Execute the copy or move. Specify a seed for deterministic
                                   behavior
    -h, --help                     Print help information
    -m, --move-files               Whether to move the files from IN_DIR to OUT_DIR, rather than cp
    -n, --num-files <NUM_FILES>    The number of files to select [default: 1]
    -s, --seed <SEED>              The seed to use for the PRNG (u64)
    -V, --version                  Print version information
Commit count: 107

cargo fmt