In a recent customer project, I had the problem that files were not being processed because of the timestamp. In short, I needed the current time as timestamp. In Unix, the appropriate command is as simple as:
touch <filename>
Code language: Shell Session (shell)
There doesn’t seem to be such a command for Windows resp. Powershell. After some quick research, I came up with the following one-liner that did exactly what I needed:
(Get-Item <filename>).LastWriteTime = (Get-Date)
Code language: PowerShell (powershell)
The Get-Item
command is described here in detail: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-item. The properties of the FileSystemInfo
object that is returned by Get-Item
can be found here: https://learn.microsoft.com/de-de/dotnet/api/system.io.filesysteminfo#properties. In the example I use LastWriteTime
, another useful timestamp could be CreationTime
.