Unified Parameters System

From TotalcmdWiki
Revision as of 21:03, 2 June 2006 by Sheepdog (talk | contribs) (backlink)
Jump to navigation Jump to search

Introduction

Total Commander allows to use template parameters in the following tools:

  • Buttonbar
  • Menu Start

These templates allow to insert into the command line such parameters as: current file name (with or without path), list of the selected files (a temporary file is created for that) and so on. All the templates are described in the Help file.

However, the current system of these templates is far from perfect: it is not regular, and also many tasks are impossible to perform with it (for example, to take the list of files on the inactive panel). Here the new unified system is presented.

Description

First, all current templates (like %P, %N, %O and so on) remain valid for compatibility with the older versions. But some of the templates can be extended, and some new ones can be added.

New template %S

%S stands for the source path without the trailing backslash (\) (this is the difference with %P).

Extended template %L

%L can be used in the following format: %L{<format>}.
<format> here means the formatting line that will be used to create the temporary file with the list of files.

Examples:

  • %L{%P%N} - same as the old %L.
  • %L{%p%n} - same as the old %l (lowercase L).
  • %L{%N} - same as the old %F.
  • %L{%n} - same as the old %f.
  • %L{%P} - list of the paths to the selected files with trailing backslashes (no old analogue).
  • %L{%S} - list of the paths to the selected files without trailing backslashes (no old analogue).
  • %L{%O.txt} - list of the names of the selected files with 'txt' extensions instead of the real extensions (no old analogue).

Notes:

  • %l (lowercase L) without the formatting parameters is the same to the %L{%p%n} (same to the old behaviour).
  • %l (lowercase L) with the formatting parameters behaves absolutely equal to %L with the same parameters. Provided for compatibility only.

New template %C

%C is used for creating the counters. Can be used as the formatter in file lists. It can be customized in the same manner as in Multi-Rename Tool, but all the parameters should be enclosed in braces.

Examples:

  • %L{%C. - %P%N} creates the list formatted as following:
1. - c:\path1\file1.ext
2. - d:\path2\file2.ext
3. - e:\path3\file3.ext
  • %L{%C{10+2:3}_%N} creates the list formatted as following:
010_file1.ext
012_file2.ext
014_file3.ext

New template %@

%@ is the analogue of the %L template, but instead of creating a temporary file with the list, %@ passes all the file names (formatted as specified) directly into the command line. The items are separated by spaces.

Examples:

  • %@{%C-%P%N} passes to the command line the following text:
1-c:\path1\file1.ext 2-d:\path2\file2.ext 3-e:\path3\file3.ext
  • %@{%C{10+2:3}_%N} passes to the command line the following text:
010_file1.ext 012_file2.ext 014_file3.ext

Note:

  • %@ without the formatting parameters is the same to the %@{%p%n}.

New template %B

%B when used inside %L format string, inserts the new line character into the file list. When it is used inside %@ format string, inserts nothing.

Example:

  • %L{%C.%B%P%N} creates the list formatted as following:
1.
c:\path1\file1.ext
2.
d:\path2\file2.ext
3.
e:\path3\file3.ext

New template %A

%A just inserts 0 if the left panel is currently active, and 1 if the right panel is active. Useful for external scripting.

Additional modifiers: prefixes

Directly after the percent sign can be an additional modifier specified, that allow to specify some options, for example - the panel, from which TC should take the list of files. All modifiers are combined into groups. Only prefixes from different groups can be used together!

Group 1 (file panel)

  • ! - means the inactive panel.
  • < - means the left panel.
  • > - means the right panel.

Group 2 (encoding)

  • $ - means that the list should be in Unicode (UTF-16LE) format.
  • # - means that the list should be in DOS (8.3) format.

Examples:

  • %!P is the same to the old %T.
  • %#P is same to the old %p.
  • %>$P means that TC should create the Unicode-formatted list of the selected files from the right panel.
  • %$#P forbidden, as $ and # prefixes are in the same group!

Additional modifiers: postfixes

After the template an additional postfix can be specified to limit the maximum number of files to pass. The format is:

:<n>, where <n> is the number.

Examples:

  • %L{%C. %N}:2 creates the list formatted as following and containing not more than 2 files (even if there are more files selected!):
1. file1.ext
2. file2.ext
  • %@{%C_%N}:2 creates the list formatted as following and containing not more than 2 files (even if there are more files selected!):
1_file1.ext 2_file2.ext

Note:

  • %L:<n> and %@:<n> are equal to %L{%P%N}:<n> and %@{%P%N}:<n> respectively.

Special characters

To insert one of the special characters (that are used for formatting) one should use the percent sign in front of it.

Examples:

  • %% inserts the % sign.
  • %{ inserts the { sign.
  • %} inserts the } sign.
  • %: inserts the : sign.



Back to Internal_functions_Ideas_and_suggestions