3

I am trying to write up a batch file that would run a schedule where it would get an log file in xml. Now whenever the batch file would run it would get it for today.

This is what I written very basic, Maybe reason why I am getting it wrong.

svn log -v -r {%date%} --xml http://repositorylocation.com > op7.xml

Now when I do that I get not only the date i need but the three letter ancrynom for day. And i need that removed but dont know how . Any advice?

I am running this on Windows XP.

Thank you.

bahrep
  • 26,679
  • 12
  • 95
  • 136
Gilbert V
  • 1,006
  • 4
  • 15
  • 41
  • Do you have cygwin? sed/awk or perl is great for manipulating strings... – Gus Aug 03 '12 at 21:28
  • 1
    `%date%` format is governed by short date format (regional settings), so simplest would be to just set that to whatever you need. It you can't, or do not want to set it user wide, you could check techniques in [this answer](http://stackoverflow.com/questions/10945572/windows-batch-formatted-date-into-variable) – wmz Aug 03 '12 at 21:49

2 Answers2

2

http://subversion.tigris.org/issues/show_bug.cgi?id=2849

The above seems to suggest that you could effect the date format by tweaking your locale, but that's a pretty bad hack... If the date format you are getting is reliably adding 0's in front of month and day hatbyzero's might work

The painful but extremely reliable way to do it is to parse the xml, parse the date and then reformat the date, set the value in the xml and then write the the fixed xml to a file This might be doable in groovy using xml slurper.

http://groovy.codehaus.org/Reading+XML+using+Groovy%27s+XmlSlurper

Gus
  • 6,132
  • 6
  • 32
  • 53
1

Try the following:

set MONTH=%date:~4,2%
set DAY=%date:~7,2%
set YEAR=%date:~10,4%

That should give you the Month, Day, and Year, respectively. You can then handle that in your log file any way you want, i.e.

svn log -v -r {%MONTH%-%DAY%-%YEAR%} --xml http://repositorylocation.com > op7.xml
hatboyzero
  • 1,842
  • 1
  • 21
  • 43