Nemo right-click action for filenames with special characters

434 Views Asked by At

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 #.

1

There are 1 best solutions below

0
On

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

The 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])