Skip to content

Instantly share code, notes, and snippets.

@d-Rickyy-b
Created November 13, 2017 15:40
Show Gist options
  • Save d-Rickyy-b/cfbb2e8792f533f9145bc4daaeb7b60b to your computer and use it in GitHub Desktop.
Save d-Rickyy-b/cfbb2e8792f533f9145bc4daaeb7b60b to your computer and use it in GitHub Desktop.
A simple script for changing the creation date and the modify date of files of a folder
# This script switches the file "creation time" with the file "last modified" time
# Scripted by d_Rickyy_b on 11.09.2017
# Telegram: https://t.me/d_Rickyy_b
# Usage: scriptName.ps1 [-path] C:\path\to\folder [-filter] "*.txt"
# Both parameters are optional!
param (
[string]$path = $PSScriptRoot,
[string]$filter = "*"
)
Get-ChildItem -Path $path -Filter $filter |
Foreach-Object {
$CreationDate = $_.CreationTime
$FileName = $_.Name
$ModifyDate = $_.LastWriteTime
Write-Host "Name: $FileName, CreationDate: $CreationDate, ModifyDate: $ModifyDate"
$_.CreationTime = $ModifyDate
$_.LastWriteTime = $CreationDate
}
Write-Host "`nDates switched :)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment