I want to copy a file and add today's date to its name. I thought it would work like this:
$DATE = Get-Date
Copy-Item -Path $HOME\AppData\Roaming\LibreOffice\4\user\wordbook\standard.dic -Destination $HOME\Desktop\standard_$DATE.dic
However, it doesn't. How can it be done?
CodePudding user response:
Try this:
$DATE = Get-Date -UFormat "%m-%d-%Y"
$outname = "standard" "_" $DATE
Copy-Item -Path C:\Temp\Test\Testfile.dic -Destination C:\Temp\Test\$outname.dic
Output:
standard_10-04-2021.dic