FYI, to quickly set folder timestamps after their content I use a PowerShell script, a user command, and a button like these:
button bar:
Code: Select all
TOTALCMD#BAR#DATA
em_redate_folders_by_content
WCMICON2.DLL,80
PowerShell: Redate folders by content recursively
0
10026
user command (usercmd.ini):
Code: Select all
[em_redate_folders_by_content]
cmd=pwsh -c "%commander_path%\Plugins\app\Date\PowerShell\redateFolders_byContent.ps1"
PowerShell script (redateFolders_byContent.ps1):
Code: Select all
$timer = [system.diagnostics.stopwatch]::StartNew()
Get-ChildItem -force -recurse -directory|foreach {
Get-ChildItem $_ -force -recurse -file|Measure -property LastWriteTime -maximum|Tee -var max|out-null # latest
(Get-Item $_.FullName).LastWriteTime = Get-Date $max.Maximum # latest
"{0:yyyy}-{0:MM}-{0:dd} {0:hh}:{0:mm}:{0:ss} {1}" -f $_.LastWriteTime,$_
}
$timer.Stop();"";"Timer : {0:mm}:{0:ss}.{0:fff}" -f ($timer.Elapsed);sleep -s 3
NB
The above code sets a folder's [Modification a.k.a. Write a.k.a. LastWriteTime*] date/time after the latest file inside.
To do the same after the earliest file inside, just change '-maximum' and '.Maximum' properties to '-minimum' and '.Minimum' ones.
A variable name '$max' doesn't actually matter, though you can also change it there to '$min' just respecting harmony.
* Understanding the Date/Time namings:
Code: Select all
PowerShell Windows Total Commander
.LastWriteTime Modification tc.writedate, tc.writetime
.CreationTime Creation tc.creationdate,tc.creationtime
.LastAccessTime Access tc.accessdate, tc.accesstime
In Total Commander it is LastWriteTime/Modification/Write Date/Time ([=tc.writedate.D-M-Y h:m] or so) that we see in the 'Date' column by default.
'pwsh' in user command implies cross-platform PowerShell (v7+)** is being utilized here.
Edit
** It took me a while to make it work in Windows PowerShell (v5.1) as well. Explicitly putting .FullName property to the current pipeline item when getting its .LastWriteTime property value appeared to be enough to do the trick, so I changed the script to fit both v7 and v5.1 simultaneously.
user command for Windows PowerShell (v5.1) would be as follows (just to change the name of the executable from 'pwsh' to 'powershell'):
Code: Select all
[em_redate_folders_by_content]
cmd=powershell -c "%commander_path%\Plugins\app\Date\PowerShell\redateFolders_byContent.ps1"