Git Product home page Git Product logo

randfiles's Introduction

Overview

This little utility can be used to choose a random selection of files from a given directory and output the list to stdout. The invocation looks like this:

randfiles [options] [dir1, [dir2, [...]]]

If no directories are given, the current directory is used. The possible options are:

  • -s, --size-limit [SIZE]: Set a size limit for the selected files. For example, randfiles --size-limit 400MB will select up to 400MB of files.
  • -c --count [N]: Set the maximum number of files. randfiles --count 3 would only choose three random files.

Examples

To copy a random selection of music to a flash drive, limited to 3GB, you can do this:

randfiles --size-limit 3GB ~/music | xargs -i -d'\n' cp -v {} /mnt/usb

If you're unfamiliar with xargs:

  • -i replaces all occurrences of {} with what's read as input
  • -d'\n' ensures that the items are delimited by newlines (there may be spaces in the file names)

Installation

The project is available as a gem, so this should be enough:

gem install randfiles

Todo

  • A -0 option for easier piping
  • Filtering files by regex or glob

randfiles's People

Contributors

andrewradev avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.