Most file rename applications on Linux are GUI based and does the job using regular expressions under the hood. While regex experts can do the same from the cmdline using a trivial script, it’s not that simple for regular users. massren is a cmdline utility written in Go that comes handy.

massren allows the user to use his favourite text editor, CLI or GUI. It opens a new temporary file in the editor with all the entries (or optionally entries matching a pattern) in the current directory. The user then modifies the filename entries as he wants. On saving the file, massren reads it line by line and renames the entries which are changed. Note the order and number of entries should remain intact for this logic (and massren) to work. Unchanged lines are ignored.

If your editor supports it, you can actually use regex to modify (search and replace) the filenames in the editor and indirectly benefit from regex.

Features

Rename multiple files using your own text editor (e.g. vim, emacs, Sublime Text or notepad).

Undo – any rename operation can be undone.

Dry run mode – test the results of a rename operation without actually renaming any file.

Cross-platform – Windows, OSX and Linux are supported.

Safety checks – since this is a multiple rename tool, various checks are in place to ensure that nothing gets accidentally renamed. For example, the program will check that the files are not being changed by something else while the list of filenames is being edited. If the number of files before and after saving the file is different, the operation will also be cancelled.

Installation

$ go get -u github.com/laurent22/massren $ sudo go install github.com/laurent22/massren

Usage

Configuration

To check all supported configuration options:

$ massren -ch

Set a value:

$ massren --config

List all configured values:

$ massren --config

Delete a value:

$ massren --config

Available configuration options:

editor: The editor to use when editing the list of files. Default: auto-detected. use_trash: Whether files should be moved to the trash/recycle bin after deletion. Possible values: 0 or 1. Default: 1. include_directories: Whether to include the directories in the file buffer. Possible values: 0 or 1. Default: 1. include_header: Whether to show the header in the file buffer. Possible values: 0 or 1. Default: 1.

Commands

Syntax: massren [OPTIONS] Application Options: -n, --dry-run Don't rename anything but show the operation that would have been performed. -v, --verbose Enable verbose output. -c, --config Set or list configuration values. For more info, type: massren --config --help -u, --undo Undo a rename operation. Currently delete operations cannot be undone (though files can be recovered from the trash in OSX and Windows). eg. massren --undo [path] -V, --version Displays version information. Help Options: -h, --help Show this help message

Examples

Process all the files in the current directory:

$ massren

Process all the JPEGs in the specified directory:

$ massren /path/to/photos/*.jpg

Undo the changes done by the previous operation:

$ massren --undo /path/to/photos/*.jpg

Set VIM as the default text editor:

$ massren --config editor vim

On GitHub: massren