This is a mirror of the GitLab repo! https://gitlab.com/Lynnesbian/fif
Find a file
2021-04-14 19:08:52 +10:00
.idea added architectures test to test.py, PKGBUILD for arch distros 2021-04-07 05:20:49 +10:00
pkg added architectures test to test.py, PKGBUILD for arch distros 2021-04-07 05:20:49 +10:00
src Merge branch 'master' of https://git.bune.city/lynnesbian/fif 2021-04-14 19:08:52 +10:00
.drone.yml don't test on alpine since it's currently broken due to a crate out of my control 0uo 2021-03-12 04:05:03 +10:00
.gitignore added architectures test to test.py, PKGBUILD for arch distros 2021-04-07 05:20:49 +10:00
Cargo.lock added .rpa format support, new system extension set 2021-04-14 19:08:18 +10:00
Cargo.toml new release! 0u0 2021-04-14 17:27:44 +10:00
CHANGELOG.md updated changelog 2021-04-14 18:43:39 +10:00
clippy.sh add option for following symlinks, make extensions optional, new version!! 2021-04-04 23:52:16 +10:00
Cross.toml windows support! and other stuff 2021-02-20 03:57:36 +10:00
LICENSE better error handling and pattern matching, added license 2021-02-05 15:57:21 +10:00
README.md much better README 2021-04-07 01:47:12 +10:00
rustfmt.toml removed an unecessary allocation 2021-03-12 02:55:40 +10:00
test.py added architectures test to test.py, PKGBUILD for arch distros 2021-04-07 05:20:49 +10:00

fif

Version License Minimum Supported Rust Version CI Status unsafe forbidden

A command-line tool for detecting and optionally correcting files with incorrect extensions.

fif recursively scans the given directory and outputs a shell script to fix the name of any files with incorrect extensions. By default, fif will scan all non-hidden files in the given directory, and will ignore symlinks.

As fif prints a shell script to stdout rather than acting on the files directly, you may wish to redirect its output to a file, e.g. fif ~/Documents > output.sh. You can also pipe the output directly into your shell, e.g. fif ~/Documents | bash, although this is not recommended - you should look over fif's output and verify for yourself that it's not doing anything that will give you a headache before running it.

Installation

Cargo

cargo install --locked fif

To update, simply re-run this command, or use a tool like cargo-update.

Other backends

fif supports using infer or xdg-mime as its backend for looking up file types. By default, xdg-mime will be used on *nix systems (Linux, macOS, *BSD, etc.), and infer on all other systems.

xdg-mime should work on any *nix system with libmagic/file(1) installed, although I've only tested it on Linux and FreeBSD. infer should work on any system.

You can override the default backend for your system at compile time like so:

# xdg-mime
cargo install fif --features=xdg-mime-backend
# infer
cargo install fif --features=infer-backend

Of the supported backends, xdg-mime by far supports the most file types, as it uses the excellent Shared MIME Info database, whereas infer uses its own baked-in database. However, infer is also faster to load, if only by a few dozen milliseconds, and has no external dependencies.

Multithreading

It is also possible to disable multithreading by installing without default features:

cargo install fif --no-default-features

Usage

See fif --help for more.

Logging

By default, fif will log any warnings and/or errors encountered during execution. The verbosity of the logging can be modified by the RUST_LOG to one of: trace, debug, info, warn, error.

For example:

RUST_LOG=debug fif ~/Downloads

The basics

The simplest way to use fif looks like this:

fif ~/Downloads

This command will scan all non-hidden files in your ~/Downloads directory.

You can also manually specify a set of extensions to use:

fif -e jpeg,jpg,zip,docx ~/Documents

Or a set of extensions - for example, to scan files with image extensions (jpg, png, gif, bmp...):

fif -E images ~/Pictures

For more information, see the man page

Output

By default, fif will output a bash script (or PowerShell script on Windows) that can be used to fix all the files it found with incorrect file extensions.

You might find it useful to output this script to a file (rather than to stdout):

fif -E images ~/Pictures > output.sh

You can also manually specify an output format to use:

fif -O powershell ~/Documents > output.ps1