0

I need to save the data of a java program into a file. The problem is, it returns a "The filename, directory name, or volume label syntax is incorrect" error when I add the %DATE% and %TIME% variables into the filename. Without the date time variables it works fine.

As well I need to output the result into the console and the file. As far as I have seen, there is no direct possibility to do so. Workaround: I'm just reading the file again into the console. When doing that with the date time variable, I get the same error.

set datetime="%DATE%-%TIME%" java -Xmx1024m -jar org.hl7.fhir.validator.jar generated.json -version 4.0.1 -ig hl7.fhir.uv.livd > "errlog/%datetime%.log" type "%CD%\errlog\%datetime%.log" 

I never write batch files so could be a very "stupid" problem. Thanks in advance!

2
  • %DATE% has / (slashes) in it, which are not valid in a filename. You need to replace the slashes with another character.
    – abelenky
    CommentedJan 28, 2020 at 13:42
  • Yeah i just realized that too. I have an european format with "hh:mm:ss.ms" and ":" are not allowed. Thanks!!
    – Eldar
    CommentedJan 28, 2020 at 13:46

1 Answer 1

1

Try this line instead:

set datetime="%DATE:/=-%-%TIME::=_%" 
0

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.