This is a mirror of the GitLab repo!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lynne Megido c3b5dbea35
CI is a bit of a pain
2 days ago
.idea CI is a bit of a pain 2 days ago
doc slightly less crummy screenshot 2 weeks ago
src mime_extension_lookup takes essence_str directly, videos aliases to video 2 days ago
.drone.yml use Cargo.lock w/ CI 2 weeks ago
.gitignore removed PKGBUILD 2 weeks ago
.gitlab-ci.yml CI is a bit of a pain 2 days ago
.mailmap consider lynne/lynnesbian to be the same author 3 weeks ago mime_extension_lookup takes essence_str directly, videos aliases to video 2 days ago
Cargo.lock added JSON output 4 days ago
Cargo.toml added JSON output 4 days ago
Cross.toml windows support! and other stuff 3 months ago
LICENSE better error handling and pattern matching, added license 3 months ago remove drone build status from readme 3 days ago numerous CI improvements =u= 2 weeks ago
rustfmt.toml new and improved rustfmt 4 days ago exit on non-zero exit code 2 weeks ago


A screenshot demonstrating fif's ability to detect the correct file extensions for a few files.

Version Minimum Supported Rust Version License Build 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 > 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.



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.


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

cargo install fif --no-default-features


See fif --help for more.

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


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 >

You can also manually specify an output format to use:

fif -O powershell ~/Documents > output.ps1


By default, fif will log any info, warnings, and errors encountered during execution. This can be changed with the -v flag:

# also log debug info
fif -v ~/Downloads
# ...and trace info
fif -vv ~/Downloads

You can also reduce the level of logging with the -q flag:

# don't show info
fif -q ~/Downloads
# ...or warnings
fif -qq ~/Downloads
# ...or even errors!
fif -qqq ~/Downloads

The verbosity of the logging can also be modified by setting the environment variable RUST_LOG to off, trace, debug, info, warn, or error. Values set by RUST_LOG override the -v and -q flags.

For example:

# show all levels except trace
RUST_LOG=debug fif ~/Downloads
# only show errors
RUST_LOG=error fif ~/Downloads

The five logging levels are used as follows:

Level Description Example
error Errors that cause fif to stop running fif was unable to open the provided directory
warn Warnings that don't cause fif to stop running fif was unable to determine the mime type of a given file
info Information pertaining to fif's status The provided directory was scanned without issue, and no files are in need of renaming
debug Debug information - usually not important to end users The list of extensions fif will consider
trace Trace info - usually not important to end users "Found 15 items to check", "Scan successful", etc.