LCarvalho
LCarvalho

Reputation: 103

Modifying attributes of a file using the filename as reference

Forgive me if this question does not fit into this site.

If it does not fit, please migrate.

First question:

Is it possible for some software to automatically change the "Creation Date" and "Modification Date" attributes of a file using the filename as a reference?

Second question:

If it is possible to do this, could anyone indicate one with this ability?

Upvotes: 0

Views: 25

Answers (1)

Neil
Neil

Reputation: 11889

The answer is yes, but how you go about it, depends on which OS you are using (Windows and Linux use different commands).

Foe example, on Windows/Powershell:

Function Set-FileTimeStamps
{
   Param (
       [Parameter(mandatory=$true)]
       [string[]]$path,
       [datetime]$date = (Get-Date))
   Get-ChildItem -Path $path |
   ForEach-Object {
       $_.CreationTime = $date
       $_.LastAccessTime = $date
       $_.LastWriteTime = $date }
   } 
}

Upvotes: 1

Related Questions