• Stars
    star
    1,338
  • Rank 35,129 (Top 0.7 %)
  • Language
    Go
  • Created almost 11 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

massren - easily rename multiple files using your text editor

Massren Build Status

Massren is a command line tool that can be used to rename multiple files using your own text editor. Multiple-rename tools are usually difficult to use from the command line since any regular expression needs to be escaped, and each tool uses its own syntax and flavor of regex. The advantage of massren is that you are using the text editor you use every day, and so can use all its features.

The tool works by creating a file that contains the filenames of the target directory, and opening this file in the text editor. You can then modify the filenames there directly. Once done, save the text file and the files will be renamed. Lines that are not changed will simply be ignored.

Massren usage animation

Features

  • Rename multiple files using your own text editor. It should work with any text editor, including vim, emacs, Sublime Text or notepad.

  • Undo - any rename operation can be undone.

  • Move files to sub-directories. See these instructions for more information.

  • 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

The latest executables for each platform are available from the release page.

Mac OS

The easiest way is with Homebrew:

brew install massren

Alternatively, the Linux method described below should work.

If the installation fails, please follow the instructions below.

Linux

  • Install Go
  • Run go install github.com/laurent22/massren@latest

By default, the tool will be installed in $GOPATH/bin/massren. From there, you can either symlink it to /bin or add $GOPATH/bin to your PATH variable with export PATH=$PATH:$GOPATH/bin.

Note that it is compatible with Linuxbrew, so the same commands as for Mac OS would work too.

Windows

The executable can be downloaded from https://github.com/laurent22/massren/releases

Note: Windows releases are discontinued as of version 1.3, as I do not know if they are used by anyone. The program still works with Windows though, and can be built and installed using the "Linux" method above. If you have any interest in maintaining the Windows releases, please let me know.

Usage and examples

Usage:
  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

  List config values:
  % massren --config

Configuration

Type massren --help --config (or massren -ch) to view the possible configuration values and defaults:

Config commands:

  Set a value:
  % massren --config <name> <value>

  List all the values:
  % massren --config

  Delete a value:
  % massren --config <name>

Possible key/values:

  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.

Examples:

  Set Sublime as the default text editor:
  % massren --config editor "subl -n -w"

  Don't move files to trash:
  % massren --config use_trash 0

TODO

  • Move files to trash in bulk instead of one by one.
  • Detect default text editor on Windows.
  • Disambiguate filenames when processing two or more folders that contain the same filenames.
  • Other various issues.

Building from source

  • Go 1.3+ is required

      go get github.com/laurent22/massren
      go build
    
  • If it doesn't build on OSX, try with:

      go get -x -ldflags -linkmode=external github.com/laurent22/massren
    

More info in this issue.

Test units

Massren functionalities are supported by a robust test suite that has nearly complete code coverage. To run the test units, type go test -v from the source code directory.

License

The MIT License (MIT)

Copyright (c) 2013-2016 Laurent Cozic

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
TypeScript
45,447
star
2

rsync-time-backup

Time Machine style backup with rsync.
Shell
3,364
star
3

joplin-android

Android releases for Joplin
234
star
4

so-sql-injections

SQL injection vulnerabilities in Stack Overflow PHP questions
PHP
161
star
5

ripple

Ripple is a REST API library for the Go programming language. Demo is available below:
Go
138
star
6

wslpath

wslpath - Converts Unix and Windows format paths in WSL
PHP
92
star
7

fastcopy

FastCopy
C++
65
star
8

pmcctv

pmcctv - poor man's CCTV system in Go
Go
56
star
9

toml-go

Toml parser in Go
Go
47
star
10

joplin-nextcloud

Joplin Web API for Nextcloud
JavaScript
45
star
11

appetizer

Official repository for Appetizer, the open source application launcher, or dock, for Windows.
C++
36
star
12

go-sqlkv

An SQL-based key/value store for Golang
Go
36
star
13

ical-go

iCal package for Go (Golang)
Go
35
star
14

pmcam

Poor man's video capture with motion detection in Bash
Shell
34
star
15

go-trash

Cross-platform package to move stuff to the OS trash
Go
19
star
16

Kohana-Mustache

A Mustache module for Kohana.
PHP
14
star
17

github-actions-logs-extension

Display GitHub Action Raw log in color, converting the Ansi colors to HTML
JavaScript
11
star
18

joplin-turndown-plugin-gfm

Fork of turndown-plugin-gfm for Jopin
JavaScript
9
star
19

simple-gettext

C++
9
star
20

joplin-turndown

JavaScript
8
star
21

gannet

A database migration tool in PHP
PHP
7
star
22

joplin-renderer

Markdown and HTML renderer for Joplin
JavaScript
5
star
23

proxy-tester

Go application to test web proxies
Go
5
star
24

ripple-demo

A demo application for Ripple, the REST API framework for Go
Go
5
star
25

joplin-plugin

JavaScript
4
star
26

kimai-desktop

Desktop client for Kimai
C++
4
star
27

poparser

This a PHP parser for Gettext PO files. It can extract the strings and translations from the file. It can also provide statistics about the state of the translation - i.e. how many strings have been translated, how many are fuzzy, etc. which is useful to provide translation reports.
PHP
4
star
28

homebrew-massren

Homebrew tap for massren. NOTE: massren is now officially on Homebrew at https://github.com/Homebrew/homebrew-core/blob/master/Formula/massren.rb
Ruby
3
star
29

laurent22.github.io

https://laurent22.github.io/so-injections/
HTML
3
star
30

tkwidgets

JavaScript
2
star
31

kache

Simple cache system for PHP with support for multiple drivers.
PHP
2
star
32

go-torrent

Golang package to build a torrent client
Go
2
star
33

laurent22

1
star
34

androidsync

Android Sync is a command line tool to synchronize an Android phone with Windows, Mac OS X or Linux via adb
Go
1
star
35

generator-joplin

Scaffolds out a new Joplin plugin
TypeScript
1
star
36

akview

Command line based image viewer and editor
C++
1
star
37

ipify-www

The public facing website for ipify.org.
HTML
1
star