Skip to content

🎲 Simple command-line tool for Windows useful for opening random files.

License

Notifications You must be signed in to change notification settings

dgltorress/rfopener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Random File Opener

Simple command-line tool for Windows used to open a random file selected from a directory and its subdirectories.

The LICENSE applies to all source code unless otherwise specified.

Overview

To open a random file, simply use:

rfopener

on the directory that contains your pool of files (whether they be in the root directory or any subdirectory).

This command will:

  1. Recursively iterate through the working directory and its subdirectories, up to the specified depth.
  2. Store the root path and each individual relative path into memory.
  3. Wait for key presses.
    1. When Enter or Space are pressed:
      1. Pick a random relative path and concatenate it to the root path.
      2. Execute the result.
    2. When Esc or Backspace are pressed:
      1. Exit.

By default, there are soft caps of 50000 stored paths and 10 depth levels. Both can be disabled.

Detailed example: open a random MP4 or WEBM file contained within up to 4 (inclusive) levels of depth inside the C:\Users\ME\Videos folder. Allow the program to store more than 50000 relative paths into memory.

rfopener -r "C:\Users\ME\Videos" -e "mp4;webm" -d 4 -nc

Playlist mode

Alternatively, the program can shuffle a series of file paths and allow sequential access to them. To achieve this, use:

rfopener -p

The first file on the list will open automatically. From there, the playlist can be navigated in the following manner:

  • Forward: and keys.
  • Backwards: and keys.

Files are opened as the playlist is traversed and both directions loop back to the opposite end of the playlist.

Usage

rfopener [-opts]

Options:

-h, --help Show the help message.

-r, --root directory Relative or absolute path to the root directory. Defaults to the current working directory.

-p, --playlist Enable P L A Y L I S T  M O D E, where files will be shuffled and accessible sequentially.

-x, --exclude directory1;directory2;...;directoryN Enables directory blacklisting. Directories matching any of the specified absolute or relative paths will be skipped.

-e, --extensions extension1;extension2;...;extensionN Enables file extension whitelisting. Only files that exactly match any of the specified extensions will be taken into account.

Empty strings are accounted for as well, but require a separator be explicitly included.

-d, --depth levels Maximum (inclusive) levels of depth the recursive iterator is allowed to reach (min. 0, max. 10, default. 5). 0 equals to the working directory.

-nc, --nocap Disable soft caps for storage of relative paths in memory (max. 50000 paths) and depth levels (max. 10 levels). Caps are enabled by default.