(view help text of ToString.cs as plain text)
ToString.exe, Version 1.02
Batch tool to format numbers and dates the .NET way
Usage: ToString.exe template arguments
or: some_command | ToString.exe template
Where: template string specifying how the arguments will be formated
arguments single or multiple numbers or dates to be formated
some_command command supplying the argument(s) in its standard output
(multiple lines of input will each be parsed separately)
Example: ToString "{0,6:F2}\t0x{1:X8}\t{2:dd-MM-yyyy}" "0.125" 500 2022-02-24
Returns: 0,13 0x000001F4 24-02-2022
Example: ToString "{0:yyyyMMddTHHmmssfffzzz}" %Time%
Returns: 20220225T214121172+01:00
Example: TIME /T | ToString "{0:yyyyMMddTHHmmssfffzzz}"
Returns: 20220225T214121175+01:00
Example: ToString "{0}" %Time%
Returns: 2022-02-25 21:41:21
Example: ToString "{0}" %Date%
Returns: 2022-02-25 00:00:00
Example: DIR %UserProfile%\.. | FIND "<DIR>" | ToString "{0:D}, {1:T}\t{3}"
Returns: Saturday, 1 January 2022, 09:44:00 .
Saturday, 1 January 2022, 09:44:00 ..
Wednesday, 16 February 2022, 17:22:00 Default
Wednesday, 3 February 2021, 16:46:00 Public
Saturday, 22 January 2022, 09:25:00 Rob
Quirks: Regardless of date and time separators specified in the template,
ToString may still use your culture's separators in its output.
On the other hand, it may have a problem with decimal separators
in a specified time string, even if it complies with your culture;
some code has been added to provide for this issue.
Note: Return code will be -1 if errors were encountered, otherwise 0.
Credits: Merge redirected input with command line by Atif Aziz
https://stackoverflow.com/a/749653
Written by Rob van der Woude
https://www.robvanderwoude.com
page last uploaded: 2025-10-23; loaded in 0.0073 seconds