Created
November 13, 2017 15:40
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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