Let's say you are scheduling a task that needs some date parameters
relative to when the task is run, or you are executing a for loop at the command line that needs better control
of formatting (such as zero-padding). Wouldn't it be great if you could
leverage your existing knowledge of .NET format strings, rather than having
to learn a new syntax?
StartWith allows you to do just this. It even determines the correct type
of your argument values by trying to parse them as Decimal, Double (use
scientific notation, e.g. 5E0 or -2.3E12), DateTime, TimeSpan (returns a DateTime
offset from Now), a YearMonthSpan (similar to the XPath 2 yearMonthDuration,
using ISO8601
duration syntax: e.g. P1Y2M, -P1M, that also returns a DateTime offset from Now),
and just assuming the value is a string otherwise.
Download StartWith.zip (includes C# source code and binary).
StartWith command-format-string value0 value1 ...
StartWith "echo {7}" %random% %random%E0 %random%E-2 %date% %time% P0M 0.00:00 OK0 System.Decimal 28787 1 System.Double 20863 2 System.Double 99.66 3 System.DateTime 2007-02-04 00:00:00 4 System.DateTime 2007-02-04 14:06:14 5 System.DateTime 2007-02-04 14:06:14 6 System.DateTime 2007-02-04 14:06:14 7 System.String OK OK
StartWith "\"C:\Program Files\7-zip\7z.exe\" ex{0:yyMM}.7z ex{0:yyMM}*.log" -P1Mfor loop variablesfor /l in %a in (3,1,11) do StartWith "curl -T ex0611{0:00}.log ftp://example.net/severAlogs/" %aStartWith "xcopy current.log {0:yyyy-MM-dd}.log" %date%StartWith "blat screencap{0:yyyyMMdd}.png -to root@example.com -subject \"{0:ddd} screencap\"" -1.00:00