Crates.io | file-organiser |
lib.rs | file-organiser |
version | 0.1.6 |
source | src |
created_at | 2024-03-23 21:42:44.521521 |
updated_at | 2024-04-06 13:42:28.061063 |
description | Command line file manager to list, move or delete large numbers of files in nested folders filtered by age, file extension, file name pattern and/or size range. |
homepage | |
repository | https://github.com/neilg63/file-organiser |
max_upload_size | |
id | 1183899 |
size | 632,941 |
FileOrganiser (fileorg) is a command line tool that lets you quickly list, move or delete large numbers of files in nested folders filtered by age, file extension, file name pattern and/or size range.
It does not seek to replace common utilities such as ls, (dir) and find combined with mv and rm (move or del), but provides a more transparent overview and streamlined workflow when managing large volumes of files.
This crate is still under development and I welcome feedback on its performance with different file systems. The utility uses the cross-platform WalkDir crate and should work on recent versions of Linux, Mac and Windows.
I have mainly used the development version on Linux servers to reorganise uploaded media files. Although it can only work within one file system at a time, it has no problems with mounted block storage volumes or S3 object-storage buckets that may use different file systems from the host operating system.
du -ch --max-depth 1
instead.-e jpeg,jpg
extension or -p file_name_pattern
options when filtering by name or extension on thousands of files.The following command will give you an overview of all jpeg, gif and png files in the target directories and subdirectories thereof to a max depth of 3 with a minimum file size of 5M and minimum age of 30 days.
These examples assume a system wide alias of fileorg
fileorg -e jpg,jpeg,gif,png --size 5M --max-depth 3 --before 30
The -l flag reveals individual file entries with their age, date, type and relative path.
fileorg -e jpg,jpeg,gif,png --size 5M --max-depth 3 --before 30 -l
Should you wish to move these files to a target directory, respecting the original nested file structure, add a --move flag.
fileorg -e jpg,jpeg,gif,png --size 5M --max-depth 3 --before 30 -l --move /extended-drive/media
Should you wish to delete these files, add a --delete
or -u
flag (-d
stands for max depth)
fileorg -e jpg,jpeg,gif,png --size 5M --max-depth 3 --before 30 -l --delete
--before 30
older than 30 days. For other periods, you may use the suffixes s
for seconds, m
for minutes, h
for hours, w
for weeks or y
for years, e.g. 5m
5 minutes . You may add a range either via -a (--after) or simply with a dash, e.g. -b 7-14
means between 7 and 14 days old while -b 30m-12h
means between 30 minutes and 12 hours old.--after 30
newer than 30 days . This may be combined with -b (--before) for an age range./
on Linux and Mac and \
on Windows), it will exclude all subdirectories starting from the parent directory, otherwise it will exclude all subdirectories at any nesting level. You may exclude multiple subdirectory path with comma-separated lists e.g. /node_modules,/dist
will exclude all files nested in these subdirectories.-x
flag to use full regular expressions in quotes.--pattern, -p
or --ext, -e
for more advanced pattern matching.a*
means any number of the preceding character, otherwise * is a wildcard for any characters, which in full regex mode is .*
. For simple pattern matches .
is interpreted literally, while in full regex mode it means any character and must be escaped to match a dot.--move, -m
;.git
as folder or .gitignore
as a filecargo build --release
target/release/file-organiser
Basic listing with the -g option to show stats by extension:
Show only png files older than 2 years (-b before, -e extension):
Show full listing of png files older than 2 years and larger than 50MB (-b before, -e extension, -s size, -l full listing):
Version 0.1.6 corrects a reporting bug for files newer than 5 minutes old where 1m 25s was incorrectly reported as 2m 45s owing to rounding anomaly in the f64 to u64 conversion. I added a test for the days_to_day_hours_min_secs()
function.
This is an alpha release. If anyone finds this useful, I may package it for release for the major operating systems and make all textual output localisable.