Select files by modification time with kind filtering and flexible ordering.
Project description
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
.pdffile in Downloads:newr -n 1 ~/Downloads/*.pdf
-
Show the 3 oldest
.docxfiles:newr -n 3 --reverse ~/Documents/*.docx
-
Show the newest spreadsheet file (
xlskind:.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 imageoption 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 NSelect this many files (default: 1). -
-r, --reverseSort in ascending (oldest-first) order before selecting files. -
-k, --kind KINDFilter files by kind:doc,xls,ppt,zip,image,video,audio,text, etc. -
-q, --quietSuppress all log output to stderr. -
-0, --allow-empty-resultExit successfully even if no files are found (otherwise, exits with error). -
--versionShow 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file newr-0.4.0.tar.gz.
File metadata
- Download URL: newr-0.4.0.tar.gz
- Upload date:
- Size: 421.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8df1a30daaa82f5362329e9c41974990f48d9419ed18ff9cf36352b620870694
|
|
| MD5 |
c83098e4d5df6e4d4c20aa7acb26f084
|
|
| BLAKE2b-256 |
f23cf4cb92839293ac9015b3411ae72140cd1e98f99bc694534c2179838fb957
|
File details
Details for the file newr-0.4.0-py3-none-any.whl.
File metadata
- Download URL: newr-0.4.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b2e8c446daaf8d3cd4ac361cc596d8e77b0bcf37ed71fa1d6c0f73ce2509bbd
|
|
| MD5 |
8daadcde85e10c455866c6c7176e5798
|
|
| BLAKE2b-256 |
4a528c81008a1048c78210add4e25d7b346283699088068a370b91a3537df12f
|