Master Bulk File Renaming with F2: Install, Commands, and Tips

F2 is a fast, safe Go‑based command‑line tool for batch renaming files and folders on Linux, macOS, and Windows, offering multiple installation methods, preview mode, undo, conflict resolution, built‑in variables, and powerful regex‑driven rename examples.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Bulk File Renaming with F2: Install, Commands, and Tips

What Is F2?

F2 is a command‑line utility written in Go that performs fast, safe batch renaming of files and directories. It works on Linux, macOS, and Windows, runs multiple validation passes before applying changes, and can undo the most recent batch operation.

Installation

Three common installation methods are supported:

Go (requires Go 1.16+)

go install github.com/ayoisaiah/f2/cmd/f2@latest

npm npm i -g @ayoisaiah/f2 Yarn yarn global add @ayoisaiah/f2 Alternatively, download a pre‑compiled binary from the GitHub releases page, extract it, make it executable, and place it in a directory that is on your $PATH:

curl -LO https://github.com/ayoisaiah/f2/releases/download/v1.6.1/f2_1.6.1_linux_amd64.tar.gz

tar -xvzf f2_1.6.1_linux_amd64.tar.gz

chmod +x f2

sudo mv f2 /usr/local/bin

Verify the installation: f2 --version Expected output (example):

F2 version v1.6.1

Key Features

String replacement, prefix/suffix insertion, case conversion, and auto‑incrementing numbers.

Full regular‑expression find‑and‑replace support.

Preview mode (omit -x) to display new names without modifying the filesystem.

Undo the last batch rename operation.

Multiple validation passes to detect conflicts such as existing target paths, invalid characters, or empty filenames.

Automatic conflict resolution with --fix-conflicts (or -F).

Built‑in variables: {{ext}} (extension with leading dot), {{f}} (filename without extension), {{p}} (parent directory), plus Exif and ID3 tag variables for media files.

Basic Usage Examples

Preview a simple replacement – replace the word “linux” with “linuxmi.com” in all filenames in the current directory: f2 -f 'linux' -r 'linuxmi.com' To apply the changes, add the -x flag: f2 -f 'linux' -r 'linuxmi.com' -x Rename audio files using ID3 tags – rename MP3 files based on their metadata:

f2 -f '.*\.mp3' -r '{{id3.artist}} - {{id3.album}} - {{id3.track}} - {{id3.title}}.mp3'

Running the command without -x shows a preview; adding -x performs the rename.

Additional Notes

F2’s conflict‑resolution flag ( --fix-conflicts or -F) automatically resolves naming collisions detected during validation. The tool’s wiki on the GitHub repository provides extensive documentation and many more batch‑rename patterns, including integration tips for file managers such as xplr.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIcross-platformBatch ProcessingGoLinuxFile Renaming
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.