Jens Jensen
Jens Jensen

Reputation: 1118

Nemo right-click action for filenames with special characters

How can I open files whose name contains sharps / hashes # from the Cinnamon Nemo right-click context menu?

A Nemo action e.g. /usr/share/nemo/actions/unzap.nemo_action which contains the line Exec=unzap "%F" will open most files, but fail to escape filenames which contain a #.

Upvotes: 1

Views: 543

Answers (1)

Jens Jensen
Jens Jensen

Reputation: 1118

Use Exec=<open.py "unzap" %F> instead of Exec=unzap "%F" in the unzap.nemo_action.

Then unescape the backslashes in open.py as follows:

#! /usr/bin/python3 -OOt

import sys
import subprocess

command = sys.argv[1]
filename = sys.argv[2].replace("\ "," ")

subprocess.run([command, filename])

Upvotes: 1

Related Questions