Skip to main content

Easily rename files and folders via your favorite text editor.

Project description

It's a bird... It's a plane...

It's Suprenam, a batch renaming utility which relies on the tool you know best: your text editor.


Sweet, but powerful

Suprenam sits in the Finder Toolbar, waiting for you to drag and drop any selection of files and folders onto it.


Then, it will open your favorite text editor with a list of names. Make use of all your superpowers to modify them: multi-cursors, Find and Replace, regular expressions, you (re)name it.

When you're done, save and close.


The modifications are instantly applied on the selected items.


Clever, reliable and fool-proof

Suprenam is not as straightforward as it seems. It supports:

  • Complex renamings. As long as the desired final state is possible (e.g. no name clash), Suprenam will abide. Under the hood, this may require it to go through intermediate names (e.g. for swapping "foo.pdf" and "bar.pdf").

  • Versioning. When an item is tracked by git, Suprenam will use git mv to keep it under version control.

  • Rollback. If something goes wrong during the actual process (e.g. a file is moved), don't worry: the work already completed will automatically be rolled back to the initial state.

  • Undo. Likewise, you can always undo the previous renaming session. To that end, simply click the Suprenam icon without dropping anything on it.


Installation

Installing the app

MacOS

Retrieving or building the installer
  • Download the latest installer from Releases under the name Suprenam.pkg. It is unsigned: that means that you'll need to right-click or ctrl-click it and select “Open”.

  • If you prefer to build it manually, follow these instructions.

  • In both cases, Suprenam requires Python 3.6 or later. You may have to install it.

Putting Suprenam in the Finder toolbar
  • Press and hold cmd while dragging the Suprenam icon to the desired location.

Linux and Windows

No graphical launcher yet. Use the command line tool.

Installing the command line tool

Although dragging and dropping the items to rename them is far more convenient, you can also launch Suprenam from the terminal. Install it with:

pip install suprenam

If this fails, try pip3 instead of pip.

Configuring Suprenam

On first launch, Suprenam creates a workspace at:

  • ~/Library/Application Support/Suprenam/ (MacOS)
  • ~/.config/suprenam/ (Linux)
  • %HOMEPATH%\"AppData\Roaming\Suprenam\ (Windows)

There, it will put the logs ("log.txt" + some backups) and a configuration file ("config.json") in which you can specify the text editor to use. For instance, VS-Code is the default when the command code is installed in your PATH; if you prefer Sublime Text, just replace the corresponding line by:

  • macOS and Linux:
      "editor_command": "subl -w",
    
  • Windows
      "editor_command": "subl.exe -w",
    

Many such commands are provided in editor_commands.md, and nothing prevents you from writing your own in the configuration file.


How it works

  • Suprenam starts by determining the items to rename. They can be provided:

    • directly, as a batch of several files of folders;
    • semi-directly, as a single folder: this folder will be renamed, along with all its children (both visible and hidden);
    • indirectly, as a single text file (mandatory suffix: .txt) containing the items to rename (one path by line). Note that a single non-text file will be treated as in the first case.
  • Suprenam retrieves the inodes of the items to be renamed. These unique numeric identifiers will serve as an invariant throughout the renaming process.

  • It creates a temporary TSV file associating each inode with its name. In case all items are siblings (i.e., have the same parent), the list is flat ; otherwise, a group is created for each parent.

  • Note that the list is sorted in “natural order” (e.g., foobar9 before foobar10, and [cote, coteau, crottez, crotté, côte, côté] as [cote, côte, côté, coteau, crotté, crottez]).

  • Suprenam opens this file by invoking the editor command found in the configuration file. If none is specified, it parses editor_commands.md and defaults to the first one that happens to work on your system.

  • Once the TSV file is opened, Suprenam waits for you to make the desired changes.

  • When it is closed, its content is parsed.

    • Any deletion or change to non-inodes lines is ignored.
    • The deletion of one, several or even all of the inodes is tolerated.
    • However, any inode creation or duplication is considered as a typo, and makes the program to abort without renaming anything.
  • The new names are checked for validity with respect to the actual file system.

  • This results in a list of bindings between existing inodes and modified names. These bindings cannot be directly translated into renaming commands, as they may lead to name clashes.

    Below, for instance, "c" has two “target“ names, which will cause Suprenam to abort…

    However, some desired bindings can be resolved along a “safe” path of renamings. For instance, the following renamings (from left to right: null, swapping, shifting, rolling) can always be obtained with careful intermediate renamings.

    A handful of accepted and rejected renaming schemes are documented (and tested) here.

  • So, whenever possible, the desired bindings have been silently converted into a “safe” sequence. The new bindings are then processed in order, and the corresponding renaming commands executed. At this stage, the only remaining possible errors should result from hardware failures or from modifications that have occurred in the file tree during the edition stage. Should such rare cases arise, all the completed renaming commands will be readily rolled back.

  • If your fate (or your footgun propensity) is relentless, and this fails too, the program will have no other choice but to leave the file system in a state which is neither the original nor the desired one. You should open the log file at ~/.suprenam/log.txt to see what went wrong and what you can do about it.

  • Suprenam can also use this log file to “undo” the previous renaming session by executing the sequence backwards. Obviously, a reversed sequence of safe renamings is still safe. Note, however, that a failed rollback cannot be automatically salvaged.

Credits

  • Authors: Aristide Grange and Alexandre Perlmutter.
  • macOS GUI: Platypus, by Sveinbjorn Thordarson.
  • Cross-plaform filename check: Python library pathvalidate, by Tsuyoshi Hombashi.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

suprenam-0.9.9b15.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

suprenam-0.9.9b15-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file suprenam-0.9.9b15.tar.gz.

File metadata

  • Download URL: suprenam-0.9.9b15.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for suprenam-0.9.9b15.tar.gz
Algorithm Hash digest
SHA256 c1727ba3be9aec0c8505854a58fabdf5d492d6e2bc2deecd7f3cf758d795e6e1
MD5 b68f8b45b0569c778f75d6bdccf17337
BLAKE2b-256 0c90b9af092db4ab79ae38a1e2da57095ed1a359bace377e35eed4f9513a24dc

See more details on using hashes here.

File details

Details for the file suprenam-0.9.9b15-py3-none-any.whl.

File metadata

  • Download URL: suprenam-0.9.9b15-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for suprenam-0.9.9b15-py3-none-any.whl
Algorithm Hash digest
SHA256 53c6d5733fce17ac3d7574469ebb6e7a799c2addb82d4c75e22153c5f9353d83
MD5 c839495fe7eaba3e1e23733c8e91df5d
BLAKE2b-256 2cbc1e39bdf0a324c23031e88d8383f42b433b5115e231a929f2be1353daa40c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page