prevnext   » SZS: Wiimms SZS Toolset » wszst: Wiimms SZS Tool » wszst split

wszst split

Analyse (file) names and split them into the different parts. Print the results in machine readable format. Wildcards and pipe characters are parsed.

Contents

1.   Syntax

wszst SPLIT [source]...

2.   Options

Options
Option Param Description
--no-wildcards Disable wildcard parsing and use each filename exactly as specified.
--in-order Process the input files in order of the command line and don't delete duplicates.
-i --ignore Ignore non existing source files without warning.
--load-prefix file Read in a PREFIX file and replace the internal prefix database with the content. https://ct.wiimm.de/export/prefix is the authoritative source for this.
--load-category file Read in a CATEGORY file and replace the internal category database with the content. https://ct.wiimm.de/export/category is the authoritative source for this.
--plus chars If a name begins with a plus sign, then all characters up to the first space are recognized as a plus prefix. The first part consists of all the plus signs followed by any other characters. The first character of the second part is used to determine the sort value. If the second part is empty, then the last plus sign is used instead.

The higher sorting value is now calculated from the number of plus signs in the first part, the more plus signs, the smaller the value. The first character from the second part determines the lower value. If it is in parameter CHARS then the position determines the value, otherwise the ASCII value to which 500 is added.

--split num >) is used as a separator. An alternative output format can be defined with the --printf option.
--printf format Add an output line with a formatted string.
--sections Dump info using configuration or section syntax. Use --var name as prefix.
--sh Dump info using SH syntax. Use --var name as prefix.
--bash Dump info using BASH syntax. Use --var name as prefix.
--json Dump info using JSON syntax. Options --var and --array are ignored.
--php Dump infos using PHP syntax. Use --var name as variable name of the resulting object.
--makedoc Dump infos using MakeDoc syntax. Use --var name as variable name of the resulting map.
--var varname Use VARNAME as variable name or prefix on script output. The default value is 'res' for variables and 'res_' as prefix.
--array Use an array on script output if possible. If arrays are not supported, then append a '_#' suffix with an zero based index to the variable name defined by --var name. In this case, only one output file is created.
--avar varname Shortcut for: --array --var name
--case case CASE is one of LOWER, AUTO (default) or UPPER.If LOWER or UPPER are set, then the lower/upper case of the variable names is adjusted accordingly.
-d --dest path Define a destination path (directory/file). The destination - means: write to standard output.

The path may contain escape sequences: %Q is replaced by the fully qualified source name. %P and %F are replaced by the source path or by the filename. %N and %E are replaced by source filename without extension or by the source extension. Finally, %T is replaced by the default extension of the destination format.

A '?' direct behind '%' in %E and %T conversions avoid that the same extension is used twice in row.

-D --DEST path Like --dest, but create the directory path automatically.

3.   --split num

Only one line with the standardized name is output. The components are divided into NUM (1-13) parts with predifined format strings. The pipe sign (|) is used as a separator. An alternative output format can be defined with the --printf option.
???

4.   --printf format

Add an output line with a formatted string.
This sections descibes the format string of option --printf=format, that is used by command wszst SPLIT to add the addional line printf="text". The write instruction SPLIT=dest,source,format of command wlect DISTRIBUTION uses the same syntax.

A string according to a format is created. The format string is composed of zero or more directives:

The convertion specification is split up to 5 parts:
%
The percent sign precedes an convertion specification.
flags
Flags is an optional sequence of special charaters to define output options. See table »Flag characters« for details.
fw (field width)
An optional decimal digit string (with nonzero first digit) specifying a minimum field width. Here the number of UTF-8 characters is counted.
.prec (precision)
An optional precision, in the form of a period followed by an optional decimal digit string. It defines the maximum number of UTF-8 characters that is copied to the output string.
string_selector
A letter that designates the type of conversion. See tables »String selectors« and »Aliases« for details.

Usually a space is printed as separator before the output of the convertion specification, but only if this output is not empty, and at least 1 character is already copied to the output string, and the character before is not another space. Exceptions are convertions %D (_d) and %E (file extention), where no spaces is added by default. Flags   and 0 override this default.

Flag characters
Char Description
- The string is to be left adjusted on the field boundary.This flag only makes sense if a field width is set.
  Force a space before the output string.
0 Suppress an auto space before the output string. The space is automatically suppressed for the first field displayed. This also applies to the first field displayed after %|.
! Suppress parenthesis, brackets and additional text.
( If the string is not empty, enclose it by (...) and ignore flag !.
{ If the string is not empty, enclose it by {...} and ignore flag !.
[ If the string is not empty, enclose it by [...] and ignore flag !.
< If the string is not empty, enclose it by <...> and ignore flag !.
+ Only insert the string if the text up to this position is used more than once. See text below for more details.
@ If set, then print standard values too (e.g. 3 laps, speed factor 1.0). If set twice, then print the standard value for an unknown value.
# Enable color support. If set twice with an alias, then use more colors.

A special feature is the flag +. At the first appearance in a convertion specification, the output string until the current position is stored in an internal list. If this string is unique, then the output of all convertion specifications with flag + are skipped. So for example format string %N%e%+v skips the version number for unique names.

Example: +A Boost: Tour GBA Rainbow {day} v2.1 (Authors) [1lap,x2] {Editors}_d.szs

String selectors
Name Example % Color Description
Pipe sign | | Print a single pipe sign as field separator and suppress the automatic space for the next displayed field. Flag characters, field width and precision are ignored.
Directory ./a/ y Directory including trailing slash.
Full name a.szs Y Complete source without directory.
Base name * F Complete file name without path, _d and extention.
_d _d D Empty or _d. By default, no additional space is inserted before the output.
Extention .szs E File extention (file type) incuding the preceding point. By default, no additional space is inserted before the output.
Normalized * O Normalized file name.
Plus Prefix +A P BLUE2 The plus prefix. It is a string that always begins with a plus sign and is always at the beginning.
Boost Prefix Boost: b RED3 The boost prefix, something like Boost:.
First Game Prefix Tour g by prefix The first part of a game prefix.
Second Game Prefix GBA G by prefix The second part of a game prefix.
Complete Game Prefix Tour GBA p by prefix The complete game prefix (first and second part).
Track Name Rainbow n The stripped track name without prefixes and additional info. Use alias %N for a name with all prefixes.
Extra info day e BLUE1 The extra info. {...} is scanned. By default output is enclosed by (...).
Version v2.1 v BLUE1 The Version string
Authors Authors a List of authors. By default it is enclosed by (...).
Editors Editor d List of editors. By default it is enclosed by (...).
Authors and Editors a,b,,e,f c Combined list of authors and editors. Editors are prefixed by ,,. By default the result is enclosed by (...).
Attributes 1lap,x2 A List of attributes. By default it is enclosed by [...].
Lap Count 1lap l BLUE1 Print the lap count with respect to flag @. Suppress "laps" if flag ! is set. If the value is not known, an attempt is made to determine it from the attributes.
Speed Factor x2 s BLUE1 Print the speed factor with respect to flag @. The leading × is suppressed, if flag ! is set. If a precision ≤0 is set, then it is used for the number of fraction digits. If the value is not known, an attempt is made to determine it from the attributes.

Aliases are abbreviations of usal sequences of directives. The color flag (#) is used to select the replacement string. All other flags are ignored.

Aliases for string selectors
Name Alias Replaced by Description
Prefixed Name %N %P%b%p%n The name of the track with all 3 prefixes (plus+boost+game).
%#N %#P%#b%#p%n
%##N %#P%#b%#p%n
Lottery %L %N%e%s%+v A good string for the track lottery: The prefixed name (alias %N) with extra and speed info. A version number is appended, if the string is not unique.
%#L %#N%e%#s%#+v
%##L %#N%#e%#s%#+v
Race %R %L\n%!a A good string for the race opening screen. It's like the lottery alias (%L), but with a second line for the authors.
%#R %#L\n%!a
%##R %##L\n%!a