What do the various % (percent)-parameters in context-menu actions or .desktop files mean?
A minimal list of these strings are defined in the section on the Exec
key of the Desktop Entry specifications. The non-deprecated ones:
-
%f
A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax. -
%F
A list of files. Use for apps that can open several local files at once. Each file is passed as a separate argument to the executable program. -
%u
A single URL. Local files may either be passed as file: URLs or as file path. -
%U
A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path. -
%i
The Icon key of the desktop entry expanded as two arguments, first --icon and then the value of the Icon key. Should not expand to any arguments if the Icon key is empty or missing. -
%c
The translated name of the application as listed in the appropriate Name key in the desktop entry. -
%k
The location of the desktop file as either a URI (if for example gotten from the vfolder system) or a local filename or empty if no location is known.
Not all of these make sense for custom actions. The LXDE Wiki suggests PCManFM supports only these.
Deprecated ones:
%d
%D
%n
%N
%v
%m
Nautilus Actions extends these to include a few more items, and I think most file managers follow that as a convention. Aside from those listed above, it adds:
-
%b
(first) basename -
%B
space-separated list of basenames -
%c
count of selected items -
%d
(first) base directory -
%D
space-separated list of base directory of each selected items -
%h
hostname of the (first) URI -
%m
mimetype of the (first) selected item -
%M
space-separated list of the mimetypes of the selected items -
%n
username of the (first) URI -
%o
no-op operator which forces a form of execution when specified as first parameter, ignored else -
%O
no-op operator which forces a form of execution when specified as first parameter, ignored else -
%p
port number of the (first) URI -
%s
scheme of the (first) URI -
%w
(first) basename without the extension -
%W
space-separated list of basenames without their extension -
%x
(first) extension -
%X
space-separated list of extensions -
%%
the « % » character
Thunar Actions supports even fewer - the ones it supports are listed in the dialog for adding actions:
-
%f
The path to the first selected file -
%F
The paths to all the selected files -
%d
Directory containing the file referred to by %f -
%D
Directories containing the files referred to by %F -
%n
The first selected filename, without the path -
%N
All the selected filenames, without paths
Both Nautilus and Thunar use specifiers which are deprecated by the Desktop Entry spec. They also use different meanings for %n
.
To summarise, it seems the only common point between the Desktop Entry Spec, Nautilus Actions and Thunar is %f
/%F
. %f
is used to specify a single file, and %F
to specify a list of files.