how to include current date into path??

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Graham Beer Graham Beer 3 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #41264
    Profile photo of tommls
    tommls
    Participant

    I know it is something sort of like this 🙂
    $Report= "C:\temp\report-$Date.html"

    I need $Report to always have current date in the file name

    I also tried
    $Report= "C:\temp\report"+$Date+".html"
    which did not work either 🙂

    Concatenating paths and variables is more complicated than strings 🙂
    I didn't find any good examples either...

    Thank you for your help,
    Tom

    #41268
    Profile photo of tommls
    tommls
    Participant

    Nvm, I finally figured out how to search for what I needed.

    I found this way:

    $Report = "C:\temp\report-$(get-date -f yyyy-MM-dd).html"

    from http://stackoverflow.com/questions/1954203/powershell-timestamp-on-file-name

    Thank you, everyone...

    #41372
    Profile photo of Graham Beer
    Graham Beer
    Participant

    Hi tommls, yes a subexpression is the way to go. A subexpression is an expression that's part of a larger expression. So by doing $("Something") will achieve what you need.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.