Skip to content

Command line options

Ayooluwa Isaiah edited this page Feb 22, 2022 · 8 revisions

This is the output of f2 --help:

DESCRIPTION
    f2 is a command-line tool for batch renaming multiple files and directories quickly and safely.

USAGE
    f2 FLAGS [OPTIONS] [PATHS TO FILES OR DIRECTORIES...]
or: f2 FIND [REPLACE] [PATHS TO FILES OR DIRECTORIES...]

AUTHOR
    Ayooluwa Isaiah <[email protected]>

VERSION
    v1.8.0

FLAGS
     --csv <csv file>
        Load a CSV file, and rename according to its contents.
        Learn more: https:/ayoisaiah/f2/wiki/Renaming-from-a-CSV-file.

    -f, --find <pattern>
        Search pattern. Treated as a regular expression by default unless --string-mode is also used.
        Defaults to the entire file name if omitted.

    -r, --replace <string>
        Replacement string. If omitted, defaults to an empty string. Supports several kinds of variables.
        Learn more: https:/ayoisaiah/f2/wiki/Built-in-variables.

    -u, --undo
        Undo the last operation performed in the current working directory if possible.
        Learn more: https:/ayoisaiah/f2/wiki/Undoing-a-renaming-operation.

OPTIONS
     --allow-overwrites
        Allow the overwriting of existing files.

    -E, --exclude <pattern>
        Exclude files/directories that match the given search pattern. Treated as a regular expression.
        Multiple exclude patterns can be specified by repeating this option.

    -x, --exec
        Commit the renaming operation to the filesystem.

    -F, --fix-conflicts
        Automatically fix conflicts based on predefined rules.
        Learn more: https:/ayoisaiah/f2/wiki/Validation-and-conflict-detection.

    -H, --hidden
        Include hidden files (they are skipped by default).

    -d, --include-dir
        Include directories (they are exempted by default).

    -i, --ignore-case
        Search for matches case insensitively.

    -e, --ignore-ext
        Ignore the file extension when searching for matches.

    -m, --max-depth <integer>
        Indicates the maximum depth for a recursive search (set to 0 by default for no limit).

     --no-color
        Disable coloured output.

    -D, --only-dir
        Rename only directories, not files (implies --include-dir).

    -q, --quiet
        Don't print out any information (except errors).

    -R, --recursive
        Recursively traverse directories when searching for matches.

    -l, --replace-limit <integer>
        Limit the number of replacements to be made on each matched file (replaces all matches if set to 0).
        Can be set to a negative integer to start replacing from the end of the file name.

     --sort <sort>
        Sort the matches in ascending order according to the provided '<sort>'.
          Allowed sort values:
            'default' : alphabetical order
            'size'    : sort by file size
            'mtime'   : sort by file last modified time
            'btime'   : sort by file creation time
            'atime'   : sort by file last access time
            'ctime'   : sort by file metadata last change time

     --sortr <sort>
        Same options as --sort but presents the matches in the descending order.

    -s, --string-mode
        Treats the search pattern as a non-regex string.

    -V, --verbose
        Enable verbose output.

    -h, --help
        show help

    -v, --version
        print the version

ENVIRONMENTAL VARIABLES

F2_DEFAULT_OPTS: override the default options according to your preferences.

F2_NO_COLOR, NO_COLOR: set to any value to avoid printing ANSI escape sequences for color output.

F2_UPDATE_NOTIFIER: set to any value to enable update notifications when using the -v or --version flag.

DOCUMENTATION
    https:/ayoisaiah/f2/wiki

WEBSITE
    https:/ayoisaiah/f2

Setting default options

F2 supports changing the default options via the F2_DEFAULT_OPTS environmental variable. This allows you to configure frequently used options to your liking. For example, you can set execute mode to be the default:

$ export F2_DEFAULT_OPTS='-x' # bash
$ set -gx F2_DEFAULT_OPTS '-x' # fish

You can set multiple options. For example, you can set execute mode, and include hidden files and directories by default with the following:

$ export F2_DEFAULT_OPTS='-x -H -d' # bash
$ set -gx F2_DEFAULT_OPTS '-x -H -d' # fish

All the options in F2 except, --find, --replace, --csv, and --undo can be set as a default option.

Clone this wiki locally