TimeStamp on file name using PowerShell

前端 未结 5 685
甜味超标
甜味超标 2020-12-07 13:18

I have a path in a string,

\"C:\\temp\\mybackup.zip\"

I would like insert a timestamp in that script, for example,

\"C:\\temp\\myb

5条回答
  •  执笔经年
    2020-12-07 13:49

    Thanks for the above script. One little modification to add in the file ending correctly. Try this ...

    $filenameFormat = "MyFileName" + " " + (Get-Date -Format "yyyy-MM-dd") **+ ".txt"**
    
    Rename-Item -Path "C:\temp\MyFileName.txt" -NewName $filenameFormat
    

提交回复
热议问题