Skip to content

Instantly share code, notes, and snippets.

@efann
Last active January 21, 2021 00:17
Show Gist options
  • Save efann/44f782811c9c93df85034d713f258447 to your computer and use it in GitHub Desktop.
Save efann/44f782811c9c93df85034d713f258447 to your computer and use it in GitHub Desktop.
Emulates Linux touch for Windows
[CmdletBinding()]
param(
[Parameter(position=0, Mandatory=$true)]
[String]$lcFolder
)
$lcDate = Get-date -Format MM/dd/yyyy" "HH:mm:ss
echo "Setting timestamp for $lcFolder"
$loFiles = Get-ChildItem -recurse "$lcFolder"
foreach($loFile in $loFiles)
{
$loFile.CreationTime=($lcDate)
$loFile.LastAccessTime=($lcDate)
$loFile.LastWritetime=($lcDate)
}
echo "Timestamps set for $lcFolder using $lcDate"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment