Skip to main content

newr

“Need to copy the last three images I downloaded—uh, what were the extensions again?”

newr is a command-line file selector that allows you to pick files by modification time, with optional filtering by file type (kind) and flexible selection with count and order controls. Supports glob patterns and MIME-type based filtering for documents, spreadsheets, presentations, and archives.

Features

  • Select files by modification time with a configurable count and optional oldest-first ordering.
  • Filter files by kind (doc, xls, ppt, zip, etc.) based on MIME type.
  • Supports glob patterns and multiple input files.
  • Quiet mode and empty-result-safe mode.
  • Outputs absolute file paths to stdout.

Installation

You can install the latest version using pipx:

pipx install http://github.com/tos-kamiya/newr

Note on Dependencies

This tool uses python-magic to determine file types. python-magic depends on the system libmagic library, so you may need to install libmagic separately depending on your OS. For more details, please refer to the official python-magic page.

Usage

newr [OPTIONS] FILES...

Examples

  • Show the newest .pdf file in Downloads:

    newr -n 1 ~/Downloads/*.pdf
    
  • Show the 3 oldest .docx files:

    newr -n 3 --reverse ~/Documents/*.docx
    
  • Show the newest spreadsheet file (xls kind: .xlsx, .xls, .ods):

    newr -k xls -n 1 ~/Downloads/*
    
  • Quiet mode (no log output), allow empty result:

    newr -q -0 -k ppt -n 1 ~/Downloads/*
    

Copy the newest image file in your ~/Pictures folder to the current directory

  • Fish shell:

    cp (newr -k image -n 1 ~/Pictures/*) .
    
  • Bash:

    cp $(newr -k image -n 1 ~/Pictures/*) .
    

The -k image option selects any file recognized as an image (such as .jpg, .jpeg, .png, .gif, etc.) based on its MIME type. In Bash, use $(...) for command substitution; in Fish, use (...).

Options

  • -n N, --number N Select this many files (default: 1).

  • -r, --reverse Sort in ascending (oldest-first) order before selecting files.

  • -k, --kind KIND Filter files by kind: doc, xls, ppt, zip, image, video, audio, text, etc.

  • -q, --quiet Suppress all log output to stderr.

  • -0, --allow-empty-result Exit successfully even if no files are found (otherwise, exits with error).

  • --version Show version and exit.

Supported Kinds

Kind Description Extensions Included
doc MS Word, ODF Text .doc, .docx, .odt
xls Excel, ODF Spreadsheet .xls, .xlsx, .ods
ppt PowerPoint, ODF Slides .ppt, .pptx, .odp
zip Zip/Tar/7z/Archive .zip, .tar, .7z, .rar, etc.

For other kinds (such as image, audio, video, text), all files whose MIME type starts with the given prefix (before the /) will be matched.

Changelog

v0.4.0: Renamed project to newr and updated CLI/tooling references. v0.3.0: Renamed project to newer and replaced --newest/--oldest with unified --number and --reverse options.

License

MIT License

Metadata

Release files for newr 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for newr 0.4.0
File Size Uploaded
newr-0.4.0.tar.gz 421.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for newr 0.4.0
File Interpreter ABI Platform
newr-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 429.5 kB

Release files / newr-0.4.0.tar.gz

Download URL newr-0.4.0.tar.gz
Size 421.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8df1a30daaa82f5362329e9c41974990f48d9419ed18ff9cf36352b620870694
BLAKE2b-256 checksum
How to use checksums
f23cf4cb92839293ac9015b3411ae72140cd1e98f99bc694534c2179838fb957
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.3

Release files / newr-0.4.0-py3-none-any.whl

Download URL newr-0.4.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b2e8c446daaf8d3cd4ac361cc596d8e77b0bcf37ed71fa1d6c0f73ce2509bbd
BLAKE2b-256 checksum
How to use checksums
4a528c81008a1048c78210add4e25d7b346283699088068a370b91a3537df12f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.3

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page