Unified Parameters System: Difference between revisions
No edit summary |
(Corrected with respect to %S introduced in TC7pb4) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 10: | Line 10: | ||
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. | 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 % | === New template %Q === | ||
<font color="red">'''% | <font color="red">'''%Q'''</font> stands for the source path '''without''' the trailing backslash (\) (this is the difference with '''%P'''). | ||
=== Extended template %L === | === Extended template %L === | ||
Line 23: | Line 23: | ||
* <font color="green">'''%L{%n}'''</font> - same as the old '''%f'''. | * <font color="green">'''%L{%n}'''</font> - same as the old '''%f'''. | ||
* <font color="green">'''%L{%P}'''</font> - list of the paths to the selected files with trailing backslashes (no old analogue). | * <font color="green">'''%L{%P}'''</font> - list of the paths to the selected files with trailing backslashes (no old analogue). | ||
* <font color="green">'''%L{% | * <font color="green">'''%L{%Q}'''</font> - list of the paths to the selected files without trailing backslashes (no old analogue). | ||
* <font color="green">'''%L{%O.txt}'''</font> - list of the names of the selected files with 'txt' extensions instead of the real extensions (no old analogue). | * <font color="green">'''%L{%O.txt}'''</font> - list of the names of the selected files with 'txt' extensions instead of the real extensions (no old analogue). | ||
'''Notes:''' | '''Notes:''' | ||
Line 45: | Line 45: | ||
014_file3.ext | 014_file3.ext | ||
=== | === Extended template %S === | ||
<font color="red">'''% | <font color="red">'''%S'''</font> is the analogue of the '''%L''' template, but instead of creating a temporary file with the list, '''%S''' passes all the file names (formatted as specified) directly into the command line. The items are separated by spaces. | ||
'''Examples:'''<br> | '''Examples:'''<br> | ||
* <font color="green">'''% | * <font color="green">'''%S{%C-%P%N}'''</font> passes to the command line the following text: | ||
1-c:\path1\file1.ext 2-d:\path2\file2.ext 3-e:\path3\file3.ext | 1-c:\path1\file1.ext 2-d:\path2\file2.ext 3-e:\path3\file3.ext | ||
* <font color="green">'''% | * <font color="green">'''%S{%C{10+2:3}_%N}'''</font> passes to the command line the following text: | ||
010_file1.ext 012_file2.ext 014_file3.ext | 010_file1.ext 012_file2.ext 014_file3.ext | ||
'''Note:''' | '''Note:''' | ||
* <font color="green">'''% | * <font color="green">'''%S'''</font> without the formatting parameters is the same to the '''%S{%N}''', as it works since introduction in TC 7.0pb4. | ||
* For compatibility reasons <font color="green">'''%P%S'''</font>, <font color="green">'''%T%S'''</font> etc. continue to work as they do since introduction in TC 7.0pb4. | |||
=== New template %B === | === New template %B === | ||
<font color="red">'''%B'''</font> when used inside '''%L''' format string, inserts the new line character into the file list. When it is used inside '''% | <font color="red">'''%B'''</font> when used inside '''%L''' format string, inserts the new line character into the file list. When it is used inside '''%S''' format string, inserts nothing. | ||
'''Example:'''<br> | '''Example:'''<br> | ||
Line 89: | Line 90: | ||
* <font color="green">'''%!P'''</font> is the same to the old '''%T'''. | * <font color="green">'''%!P'''</font> is the same to the old '''%T'''. | ||
* <font color="green">'''%#P'''</font> is same to the old '''%p'''. | * <font color="green">'''%#P'''</font> is same to the old '''%p'''. | ||
* <font color="green">'''%>$P'''</font> means that TC should create | * <font color="green">'''%>$P'''</font> means that TC should create the Unicode-formatted list of the selected files from the right panel. | ||
* <font color="green"><strike>'''%$#P'''</strike></font> forbidden, as '''$''' and '''#''' prefixes are in the same group! | * <font color="green"><strike>'''%$#P'''</strike></font> forbidden, as '''$''' and '''#''' prefixes are in the same group! | ||
Line 103: | Line 104: | ||
2. file2.ext | 2. file2.ext | ||
* <font color="green">'''% | * <font color="green">'''%S{%C_%N}:2'''</font> 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 | 1_file1.ext 2_file2.ext | ||
'''Note:''' | '''Note:''' | ||
* <font color="green">'''%L:''<n>'''''</font> and <font color="green">'''% | * <font color="green">'''%L:''<n>'''''</font> and <font color="green">'''%S:''<n>'''''</font> are equal to '''%L{%P%N}:''<n>''''' and '''%S{%N}:''<n>''''' respectively. | ||
=== Special characters === | === Special characters === | ||
Line 118: | Line 119: | ||
* <font color="red">'''%}'''</font> inserts the '''}''' sign. | * <font color="red">'''%}'''</font> inserts the '''}''' sign. | ||
* <font color="red">'''%:'''</font> inserts the ''':''' sign. | * <font color="red">'''%:'''</font> inserts the ''':''' sign. | ||
{{backlink|Internal_functions_Ideas_and_suggestions|Internal_functions_Ideas_and_suggestions}} |
Latest revision as of 14:15, 7 May 2007
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 %Q
%Q 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{%Q} - 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
Extended template %S
%S is the analogue of the %L template, but instead of creating a temporary file with the list, %S passes all the file names (formatted as specified) directly into the command line. The items are separated by spaces.
Examples:
- %S{%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
- %S{%C{10+2:3}_%N} passes to the command line the following text:
010_file1.ext 012_file2.ext 014_file3.ext
Note:
- %S without the formatting parameters is the same to the %S{%N}, as it works since introduction in TC 7.0pb4.
- For compatibility reasons %P%S, %T%S etc. continue to work as they do since introduction in TC 7.0pb4.
New template %B
%B when used inside %L format string, inserts the new line character into the file list. When it is used inside %S 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.
%$#Pforbidden, 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
- %S{%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 %S:<n> are equal to %L{%P%N}:<n> and %S{%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.