||2 days ago|
|.idea||1 week ago|
|doc||3 months ago|
|src||1 week ago|
|.drone.yml||3 months ago|
|.gitignore||1 month ago|
|.gitlab-ci.yml||1 month ago|
|.kateproject||1 week ago|
|.mailmap||3 months ago|
|CHANGELOG.md||1 day ago|
|Cargo.lock||1 day ago|
|Cargo.toml||1 day ago|
|Cross.toml||4 weeks ago|
|LICENSE||6 months ago|
|README.md||4 weeks ago|
|build.rs||2 months ago|
|clippy.sh||4 weeks ago|
|clippy.toml||2 months ago|
|rustfmt.toml||3 months ago|
|test.py||1 week ago|
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 won't do anything that will give you a headache before running it.
- ✅ Cross platform
- ✅ Multi-threaded
- ✅ Configurable
fif can be built, installed, and tested with Cargo, as with most rust programs:
git clone https://gitlab.com/Lynnesbian/fif/ cd fif # run tests (optional) cargo test --locked # build fif with its default feature set cargo build --locked --release
--locked flag ensures that Cargo uses the dependency versions specified in the lock
file, and the
--release flag builds fif with release
optimisations enabled -- this takes longer, but produces a much faster binary.
# install the fif crate (to ~/.cargo/bin or %USERPROFILE%\.cargo\bin by default) cargo install --locked fif
To update, simply re-run the
install command, or use a tool like cargo-update
, which can update crates installed via
xdg-mime should work on any *nix system with the Shared MIME Info library installed (consult your package
manager), 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 --locked --features=xdg-mime-backend # infer cargo install fif --locked --features=infer-backend
It is also possible to get a more minimal build by installing without default features:
cargo install fif --locked --no-default-features
This will disable some non-essential but nice to have features, like multi-threading support.
For more info on fif's compile-time features, see the wiki.
fif --help for more.
The simplest way to use fif looks like this:
This command will scan all non-hidden files in your
-E flags can be used to specify individual extensions and sets of extensions to scan, respectively:
# only scan files with the extensions .jpeg, .jpg, .zip, and .docx fif -e jpeg,jpg,zip,docx ~/Documents # only scan files with "image extensions" - .jpg, .png, .gif, .webp... fif -E images ~/Pictures # scan .zip files, videos, and audio fif -e zip -E videos,audio ~/Downloads
-E have equivalent
-X flags that exclude the given extensions rather than including them:
# scan everything except filenames ending in .zip fif -x zip ~/Downloads # scan all files with image extensions, but not .jpg and .jpeg files fif -x jpg,jpeg -E images ~/Pictures # scan everything except text and system files fif -X text,system ~/.local/share
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 ~/Documents > output.sh
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
# also log debug info fif -v ~/Downloads # ...and trace info fif -vv ~/Downloads
You can also reduce the level of logging with the
# 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
error. Values set by
RUST_LOG, and both override the
# show all levels except trace FIF_LOG=debug fif ~/Downloads # only show errors FIF_LOG=error fif ~/Downloads
The five logging levels are used as follows:
|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.|
For a more comprehensive explanation of all of fif's parameters and how to use them, run
fif --help (or
fif -h for
a more concise overview).