?

Log in

No account? Create an account
entries friends calendar profile Previous Previous Next Next
Code snippetry. - Ed's journal
sobrique
sobrique
Code snippetry.
OK. So if you're anything like me, you occasionally deal with log files.

Sometimes these log files are on systems which don't have anything remotely resembling a real shell.

So, here's a little snippet of usefulness:

for /F "tokens=1-3 delims=/ " %%v in ('date /T') do (
set day=%%v
set month=%%w
set year=%%x)

echo %year%%month%%day%

move D:\Legato\nsr\logs\daemon.log D:\Legato\nsr\logs\daemon.%year%%month%%day%.log



Lets me output a date in a format of YYYYMMDD, which is far more useful than most defaults because you get to sort by filename, in date order.
3 comments or Leave a comment
Comments
mister_jack From: mister_jack Date: April 16th, 2008 06:08 pm (UTC) (Link)
The awesome power of YYYYMMDD should be known to all programmers; hell, all computer users.
sobrique From: sobrique Date: April 16th, 2008 06:42 pm (UTC) (Link)
I know it's such a _trival_ thing, but for bonus points it also gets away from the rather irritating ambiguity that is created by the moronic US date format.
(Deleted comment)
3 comments or Leave a comment