Last active
March 4, 2020 12:49
-
-
Save nimatrueway/b4f2425d3e1344bdd402d16ae56e4785 to your computer and use it in GitHub Desktop.
Integration Nemo file manager with massren for bulk renaming (https://github.com/laurent22/massren)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from re import sub as rereplace, compile as recompile | |
from sys import argv | |
from urllib.parse import unquote | |
from subprocess import run | |
# prerequisites: | |
# make sure the editor you assigned to massren is assessible with default PATH (uninitialized .zshrc) | |
# constants | |
massren_exec = "{path-to-massren}/massren" | |
terminal_exec = "/usr/bin/x-terminal-emulator -e" | |
file_prefix = recompile("^file://") | |
args = [rereplace(file_prefix, "", unquote(arg)) for arg in argv[1:]] | |
massren_cmd = "{MASSREN} \"{FILES}\"".format(MASSREN=massren_exec, FILES="\" \"".join(args)) | |
cmd = "{TERMINAL} {CMD}".format(TERMINAL=terminal_exec, CMD=massren_cmd) | |
run(cmd, shell=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Nemo Action] | |
Active=true | |
Name=Mass Rename | |
Comment=Running massren in this folder. | |
Exec=konsole --workdir "%F" -e {path-to-massren}/massren | |
Dependencies={path-to-massren}/massren | |
Selection=s | |
Extensions=dir; | |
Terminal=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Nemo Action] | |
Active=true | |
Name=Mass Rename | |
Comment=Running massren in this folder. | |
Exec=konsole --workdir "%F" -e {path-to-massren}/massren | |
Dependencies={path-to-massren}/massren | |
Selection=none | |
Extensions=any; | |
Terminal=false |
To integrate "Rename..." / "F2" of nemo with massren when multiple files are selected:
- Copy
massren-nemo.py
to a desired folder (e.g.~/scripts/
) and make it executable (chmod +x massren-nemo.py
) - In the python script replace
{path-to-massren}
with the actual path of massren executable. (it should be at $GOPATH/bin/) - Open up nemo, in menus select
Edit
->Preferences
; in the opened window selectBehavior
tab. The last option isBulk Rename
and set the command to the absolute path of the python script (e.g.{your-home}/scripts/massren-nemo.py
).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To add a "Bulk Rename" action to your folders / blank area:
{path-to-massren}
with the actual path ofmassren
executable. (it should be at$GOPATH/bin/
)*.nemo_action
files to$HOME/.local/share/nemo/actions