Skip to content

Formatting strings

HDoujinDownloader edited this page May 2, 2024 · 6 revisions

HDoujin Downloader offers a lot of freedom when it comes to customizing folder and file names. This is done through the use of "formatting strings", which are strings made up of tokens that are replaced with values from the manga metadata. For example, the %TITLE% token would be replaced with the title of the manga.

Folder formatting strings

Your folder formatting string, found under Settings > Save to > General, defines the folder names used for storing the chapters/images you download. It is set to %TITLE% by default, which is replaced with the title of the manga.

Show list of supported tokens
Token Description Example
%ALT_TITLE% Alternative title of the work My Little Sister Can't Be This Cute
%ARTIST% The artist of the work Tsukasa Fushimi
%AUTHOR% The author of the work Tsukasa Fushimi
%CHAPTERS% The total number of chapters 26
%CIRCLE% The doujin circle, or the artist if there is no circle metadata available number2
%CONVENTION% The convention at which the doujin was first published C95
%ID% Numeric ID of the gallery (%GID% is an alias for this token) 278878
%LANGUAGE% The language of the work English
%MAGAZINE% The magazine in which the work was serialized Dengeki G's Magazine
%OTITLE% The original title of the work (usually in its native language) 俺の妹がこんなに可愛いわけがない
%PAGES% The total number of pages 360
%PARODY% The series that the doujin is parodying, or "Original" if it is not based on an existing series Oreimo
%PUBLISHER% The publisher of the work ASCII Media Works
%SCANLATOR% The name of the group that provided the scans Baka Scans
%SERIES% The series that the work is a part of Oreimo
%STATUS% The publishing status of the work (ongoing or completed) Completed
%TAGSORT% When tag sorting is enabled, the folder hierarchy the work falls under \comedy\romance\
%TAGS% The work's comma-delimited list of tags Comedy, Harem, Romance
%TIMESTAMP% An ISO 8601 timestamp corresponding to the current time (can be customized by providing an argument) 20200802T071230Z
%TITLE% The title of the work (%MTITLE% is an alias for this token) Oreimo
%TRANSLATOR% The name of the group that translated the work Baka Translations
%TYPE% The type of work (e.g. manga, doujinshi, game CG, etc.) Manga
%UPLOADER% The name of the gallery uploader
%VOLUMES% The total number of volumes 14
%WEB% The name of the website the work was downloaded from Pixiv

Using the above example values, the formatting string [%AUTHOR%] %TITLE% would evaluate to [Tsukasa Fushimi] Oreimo.

Advanced

"Or" token

An "or" token lets you use a fallback value in the event one of the values is unknown or empty. For example, %AUTHOR||ARTIST% evaluates to %AUTHOR% if author metadata is available, and if not, it falls back to %ARTIST%. You can combine any number of tokens in this manner.

Limiting arguments

Limiting arguments allow you to limit the number of items shown when the token evaluates to a comma-delimited list. For example, if the work has multiple artists, the %ARTIST% token might evaluate to Artist 1, Artist 2, Artist 3. This situation can result in paths that are too long for the file system to handle.

You can limit the number of items by providing an argument corresponding to the desired maximum number of items. For example, %ARTIST(1)% would evaluate to Artist 1; %ARTIST(2)% would evaluate to Artist 1, Artist 2, and so on. You can also provide a negative argument to select values from the end of the list.

Padding arguments

You can provide a padding argument to pad numeric values with 0s. For example, if %PAGES% evaluates to 10, then %PAGES(000)% would evaluate to 010. The number of 0s corresponds to the total length of the string. If the number of digits is greater than the padding length, the string is left as-is.

Some tokens are padded by default, but you can override this behavior using this method.

Conditional tokens

Conditional %IF(...)% tokens take a value evaluating to true or false and return a corresponding value. They can have as few as 1 argument and as many as 3 arguments. They can also be nested an arbitrary number of times.

A value is considered true if it is not null and not "unknown", and is considered false otherwise. The comparison operators = (equal) and != (not equal) are supported.

Show examples
Token Description Example
%IF(condition,true,false)% Evaluates to true value if condition value is truthy, false value otherwise %IF(%ARTIST%,%ARTIST%,%AUTHOR%)%
%IF(value1=value2,true,false)% Evaluates to true value if value1 is equal to value2, false value otherwise %IF(%ARTIST%=%AUTHOR%,%ARTIST%,%ARTIST%,%AUTHOR%)%
%IF(value1!=value2,true,false)% Evaluates to true value if value1 is not equal to value2, false value otherwise %IF(%ARTIST%!=%AUTHOR%,%ARTIST%,%AUTHOR%,%ARTIST%)%
%IF(condition,true)% Evaluates to true value if condition value is truthy, empty value otherwise %IF(%ARTIST%,%ARTIST%)%
%IF(condition)% Evaluates to condition value if condition value is truthy, empty value otherwise %IF(%ARTIST%)%

Note that "if A, A, otherwise B" can be expressed with "or" tokens. For example, %IF(%ARTIST%,%ARTIST%,%AUTHOR%)% is equivalent to %ARTIST||AUTHOR%.

Regex/replacement tokens

The %REGEX% token allows you to perform a regex search on a given value. For example, %REGEX(hello world,^[^\s]+)% returns the value hello. A third argument can be provided to specify a capture group name or index.

The %REPLACE% token can be used to replace substrings. For example, %REPLACE(hello world,hello,goodbye)% returns the value goodbye world.

Arguments can be enclosed in quotes if necessary. For example, %REPLACE(hello world,hello,goodbye)% is equivalent to %REPLACE("hello world","hello","goodbye")%.

Tips

  • Token names are not case sensitive, so %TITLE% and %title% are both replaced with the same value.
  • Content following the arguments list of a token is appended to the end of the token. For example, %TITLE()test% is the same as %TITLE%test.