0

Is there a Windows equivalent to the touch command?

Mokubai
  • 95,412
Isaac
  • 45

1 Answers1

2

touch.ps1

Usage: touch [FILE]...


   param(
        [Parameter()]
        [String]$file
    )
    if(Test-Path -Path $file){
        (Get-Item -Path $file) | % {$_.LastWriteTime = (Get-Date)}
    }
    else{
        (New-Item $file)
    }

Add the directory to your touch.ps1 script to the PATH environment variable and you should be set.

Isaac
  • 45