F2: Fast and safe command line batch renaming tool (cross-platform)

F2 It is a command line file and folder batch renaming tool written in Go. The tool is fast, safe (runs multiple verifications before renaming, and allows batch renaming to be undone), and it runs on Linux, macOS, and Microsoft Windows.

The batch renaming command line tool is quite new. The first stable version was released in February 2021, but it is quite mature, with string substitutions, inserting text as prefixes, suffixes or other positions in file names, and changing the size of letters Write, rename with auto-increment numbers, etc. Also supports the use of regular expressions to find and replace.

The tool can display a preview of new file and folder names (just omit -x Command line flag for applying changes), it also supports undoing the last batch rename operation, in case you change your mind and want to revert the changes.

To ensure that the rename operation is safe, F2 also runs multiple verifications before performing the rename operation.If the tool finds conflicts, such as the target destination already exists, invalid characters in the target path, empty file names, etc., it can use --fix-conficts / -F banner.

To make batch renaming easier, F2 contains several built-in variables, such as {{ext}} For file extensions (including dots), {{f}} For the original file name without the extension, and {{p}} Used for the parent directory name, etc. Exif and ID3 tags can also be used as built-in variables, so you can use their Exif data and music files based on ID3 tags (such as MP3, FLAC, OGG, M4A, ACC, etc.) to rename pictures in batches.

F2 is also fast.You can find some benchmarks on it Project page.

Although F2 has many functions, it does not have an easy-to-use user interface. You only need to check some boxes and start batch renaming. Instead, you must enter some command-line options and optionally use regular expressions to rename the file the way you want.For example, replace img with Image In the names of all files using F2 in the current directory, you would use:

$ f2 -f 'img' -r 'Image'+-------------+---------------+--------+|    INPUT    |    OUTPUT     | STATUS |+-------------+---------------+--------+| img-001.png | Image-001.png | ok     || img-002.png | Image-002.png | ok     || img-003.png | Image-003.png | ok     |+-------------+---------------+--------+

The command used in the above example only displays a preview of the original file and its new file name, but does not perform the rename operation.When you want to apply the changes, please attach -x To the order.So in this example, the above command becomes f2 -f 'img' -r 'Image' -x.

You may also like: Introduction to fzf (interactive command line fuzzy finder)

This is another example of renaming some music files (mp3) in batches 001.mp3And so on, use its audio ID3 tag to describe the name:

$ f2 -f ".*.mp3" -r "{{id3.artist}} - {{id3.album}} - {{id3.track}} - {{id3.title}}.mp3" -x+---------+----------------------------------------------------+--------+
|  INPUT  |                       OUTPUT                       | STATUS |
| 001.mp3 | Tool - Fear Inoculum - 1 - Fear Inoculum.mp3       | ok     |
| 002.mp3 | Tool - Fear Inoculum - 2 - Pneuma.mp3              | ok     |
| 003.mp3 | Tool - Fear Inoculum - 3 - Invincible.mp3          | ok     |
| 004.mp3 | Tool - Fear Inoculum - 4 - Descending.mp3          | ok     |
| 005.mp3 | Tool - Fear Inoculum - 5 - Culling Voices.mp3      | ok     |
| 006.mp3 | Tool - Fear Inoculum - 6 - Chocolate Chip Trip.mp3 | ok     |
| 007.mp3 | Tool - Fear Inoculum - 7 - 7empest.mp3             | ok     |

Please note that here I used -x Logo, it applies batch file renaming.I won’t introduce more examples here because the F2 wiki is Well documented, It includes various batch renaming examples.

You might also like: GUI that supports batch renaming of files on Linux using Exif and music tags: Inviska rename

Download F2 command line batch rename tool

F2 can be installed from the source code, or you can download pre-compiled binaries for Linux (including Termux/Android), Windows or macOS.

If you use xplr, you can find F2 xplr integration hacker Here.