The modified date of the folder reflects the changes in the modified dates of the subfolders
Moderators: Hacker, petermad, Stefan2, white
The modified date of the folder reflects the changes in the modified dates of the subfolders
Hi.
NTFS has a peculiarity - the modified date of the folder changes only if there are changes in the modified dates of the files within that folder. If changes occur in the modified dates of its subfolders, the folder does not change its modified date.
Is there a way in TC to take this feature into account and automatically change the modified date of a folder when changes in the modified dates occur in its subfolders as well?
NTFS has a peculiarity - the modified date of the folder changes only if there are changes in the modified dates of the files within that folder. If changes occur in the modified dates of its subfolders, the folder does not change its modified date.
Is there a way in TC to take this feature into account and automatically change the modified date of a folder when changes in the modified dates occur in its subfolders as well?
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
There is a similar topic.
Overquoting is evil! 👎
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
Thanks for the advice, but, IMHO, this is absolutely not what I meant in my first post.
The most closely related topic would be https://www.ghisler.ch/board/viewtopic.php?t=56937, but this plugin does not take into account the modified dates of the subfolders themselves, the modified dates of the subfolders are set even if they are younger than the files in them and all of this requires manual intervention rather than being done automatically.
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
And the folder color, in your opinion, how should it change? By searching for the newest file in the folder? No, it's not. By comparing the current date with the modification date after the date correction. The Tempus plugin, which was discussed, was used just for this when connected to the color settings.
Overquoting is evil! 👎
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
The key feature in my first post was - change the modified date of a folder not only taking into account the modified dates of files within this folder, but also the modified dates of subfolders.
But in the Tempus plugin, not only that after TС version 9.x.x it practically does not work, the main function disregards subfolders, only files - "1. Automatically updates dates of folders according to dates of the most recent files inside."
And there are a sufficient number of properly working programs, unlike the Tempus plugin, that manually redefine the modified date of a folder by the date of the youngest file within it, for example:
1. FolderTimeUpdate from NirSoft https://www.nirsoft.net/utils/folder_time_update.html
2. SetFolderDate 1.5 (AutoIT script) https://totalcmd.net/plugring/SetFolderDate.html
3. SetFolderDate 1.3.0.0 (wcx plugin) https://www.ghisler.ch/board/viewtopic.php?t=56937
But in the Tempus plugin, not only that after TС version 9.x.x it practically does not work, the main function disregards subfolders, only files - "1. Automatically updates dates of folders according to dates of the most recent files inside."
And there are a sufficient number of properly working programs, unlike the Tempus plugin, that manually redefine the modified date of a folder by the date of the youngest file within it, for example:
1. FolderTimeUpdate from NirSoft https://www.nirsoft.net/utils/folder_time_update.html
2. SetFolderDate 1.5 (AutoIT script) https://totalcmd.net/plugring/SetFolderDate.html
3. SetFolderDate 1.3.0.0 (wcx plugin) https://www.ghisler.ch/board/viewtopic.php?t=56937
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
And one of the most crucial aspects to consider is do not change the folder's modified date if it is younger than the files or subfolders within it.
Why? It would be way inconvenient if the folder created right now when unpacking the archive with drivers, the files of which have an older date than now, would be redefined to this older date.
Why? It would be way inconvenient if the folder created right now when unpacking the archive with drivers, the files of which have an older date than now, would be redefined to this older date.
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
In addition to above-mentioned methods, I wrote a PS script that works in compliance with the conditions that were written in the first post, except for one important thing - it doesn't update the dates automatically.
Is there a way for this script to work automatically in TC?
And here is the button for TC.
Is there a way for this script to work automatically in TC?
Code: Select all
#Set-PSDebug -Trace 2
# Print the full command line used to run the script
Write-Host "Script was run with the following command:"
Write-Host $MyInvocation.Line
Write-Host ""
# Function to split the input string based on the pattern "space followed by drive letter and a path"
function Split-ArgumentsByPattern {
param (
[string]$inputString
)
# Regular expression pattern to match space followed by drive letter and path
$pattern = '(?<=\s|"|^)([A-Za-z]:\\[^\/\:\*\?\"\<\>\|]+(?= [A-Za-z]:|"|$))'
# Split the string by the pattern
$folders = [regex]::Matches($inputString, $pattern) | ForEach-Object { $_.Value }
# Remove any leading or trailing whitespace from each folder path
$folders = $folders | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne "" }
return $folders
}
# Combine all arguments into a single string
Write-Host "Arguments : $args"
Write-Host ""
#$combinedArgs = $args -join " "
#Write-Host "Combined Arguments: $combinedArgs"
#Write-Host ""
# Split the combined string into individual folder paths
$rootFolders = Split-ArgumentsByPattern -inputString $args #$combinedArgs
# Print each folder path passed in the array
Write-Host "RootFolders from arguments:"
foreach ($folder in $rootFolders) {
Write-Host "- $folder"
}
# Function to update the parent folder's LastWriteTime
function Update-ParentFolderTime {
param (
[string]$folderPath
)
# Get all items (files and subfolders) in the current folder
$items = Get-ChildItem -Path $folderPath -Recurse
# Find the item with the most recent LastWriteTime
$mostRecentItem = $items | Sort-Object LastWriteTime -Descending | Select-Object -First 1
# If there's a most recent item, compare its LastWriteTime with the parent folder
if ($mostRecentItem) {
$parentFolder = Get-Item -Path $folderPath
if ($parentFolder.LastWriteTime -lt $mostRecentItem.LastWriteTime) {
# Update the parent folder's LastWriteTime to the most recent item's LastWriteTime
Write-Host "6. Updating LastWriteTime of the folder '$folderPath' from $($parentFolder.LastWriteTime) to $($mostRecentItem.LastWriteTime)" -ForegroundColor Red
$parentFolder.LastWriteTime = $mostRecentItem.LastWriteTime
} else {
Write-Host "7. The folder '$folderPath' has the most recent LastWriteTime than its child files and subfolders" -ForegroundColor DarkGreen
}
}
}
# Function to recursively process all folders starting from the bottom level
function Process-Folders {
param (
[string]$rootFolder
)
# Get all subfolders
$subfolders = Get-ChildItem -Path $rootFolder -Directory
Write-Host "1. $subfolders = Get-ChildItem -Path $rootFolder -Directory"
Write-Host "2. $subfolders"
foreach ($subfolder in $subfolders) {
# Recursively process subfolders
Write-Host "3. Process-Folders -rootFolder $($subfolder.FullName)"
Process-Folders -rootFolder $subfolder.FullName
}
# Update the currently processed root folder
Write-Host "5. Update-ParentFolderTime -folderPath $rootfolder"
Update-ParentFolderTime -folderPath $rootFolder
}
# Validate that at least one folder is provided as argument
if (-not $rootFolders) {
Write-Host '
--------------------------------------------------------
Please provide one or more root folder paths as arguments.
For example:
.\UpdateFolderModifiedDate.ps1 "C:\path\to\folder"
or
.\UpdateFolderModifiedDate.ps1 C:\path\to\folder
or
.\UpdateFolderModifiedDate.ps1 "C:\path\to\folder" "C:\path\to\another\folder" "C:\path\to\yet\another\folder"
or
.\UpdateFolderModifiedDate.ps1 C:\path\to\folder C:\path\to\another\folder C:\path\to\yet\another\folder
--------------------------------------------------------
'
# If no arguments were provided, prompt the user to enter one or more folder paths
$input = Read-Host 'Or please enter the paths of the folders you want to process (without/with quotes, just separate multiple paths with the space/s).
For example:
"C:\path\to\folder" "C:\path\to\another\folder"
C:\path\to\folder C:\path\to\another\folder
'
# If the user provided folder paths, split them into an array
if ($input) {
$rootFolders = Split-ArgumentsByPattern -inputString $input # -split ",\s*" # Split by comma, allowing for optional spaces
Write-Host "Input: $input"
Write-Host "RootFolders from input: $rootFolders"
} else {
Write-Host "No folder paths provided. Exiting script."
Set-PSDebug -Trace 0
exit 1
}
}
# Loop through each provided folder and process it
foreach ($rootFolder in $rootFolders) {
if (Test-Path $rootFolder) {
Write-Host "RootFolders from arguments: $rootFolders"
Write-Host "Processing folder: $rootFolder"
Process-Folders -rootFolder $rootFolder
} else {
Write-Host "Folder not found: $rootFolder"
}
}
Set-PSDebug -Trace 0
Code: Select all
TOTALCMD#BAR#DATA
powershell.exe -noexit -ExecutionPolicy Bypass "X:\path\to\the\script\UpdateFolderModifiedDate.ps1"
'%X%Y%P%S%T%R'
C:\Program Files (x86)\Total Commander\Wcmicons.dll,51
Change the modification date of folders to match the most recent modification date of their child files or subfolders.
-1
Last edited by iG0R on 2024-08-19, 10:31 UTC, edited 1 time in total.
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
I don't understand why you're writing this to me. I made it clear in that post that the plugin no longer works. And all other programs have nothing to do with updating the date when navigating in TC. I have known these and other programs for a long time.iG0R wrote: 2024-08-14, 17:11 UTCAnd there are a sufficient number of properly working programs, unlike the Tempus plugin, that manually redefine the modified date of a folder by the date of the youngest file within it, for example:
Overquoting is evil! 👎
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
I apologize if I offended you in any way. You mentioned the Tempus plugin, and while years ago it could update folder dates to match the dates of the most recent files in them when navigating in TC, now it doesn't work at all. That is why I wrote about other programs, because we communicate with each other and since these programs work, with some nuances, and, as I see, you are very knowledgeable and savvy in many topics, including TC, perhaps something will come to your mind at the mention of them, like how to get around their shortcomings, or maybe you can think of something that will help resolve this matter in other ways.
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
The only proper solution here is a new option in Everything's indexing settings, as it will do it dozens (maybe hundreds) of times faster than TC and any plugin, especially in service mode. I would advise you to create a topic here.iG0R wrote: 2024-08-15, 04:16 UTC or maybe you can think of something that will help resolve this matter in other ways.
Overquoting is evil! 👎
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
2iG0R
No problem. The reaction was somewhat surprising.
The program is well known here, because it has long been present as an option in the TC search dialog. It's revealed most fully in the alpha version.
No problem. The reaction was somewhat surprising.

Overquoting is evil! 👎
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
2Fla$her
A long time ago, I saw this option in the search and tree dialogs, but when I checked it, a dialog box appeared with a warning about the absence of this program and since I was satisfied with TC's functions for searching and building a directory tree, I didn't pay much attention to it.
Now I've installed it in its alpha version, and it is awesome! Thank you so much again!

Now I've installed it in its alpha version, and it is awesome! Thank you so much again!
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
2iG0R
You're welcome. I see the author responded to you by suggesting to enable the always_update_folder_recent_change=1 option, but I didn't see any date/size changes if you create something at depth 2 and below.
You're welcome. I see the author responded to you by suggesting to enable the always_update_folder_recent_change=1 option, but I didn't see any date/size changes if you create something at depth 2 and below.
void wrote:When enabled, any change made to the Everything folder database entry will cause the recent change date to update.
This includes folder size changes.
To change this setting:
In Everything, type in the following search and press ENTER:
/always_update_folder_recent_change=1
void wrote:This setting will update the date recently changed property for folders for every change single event. (even when there is no actual change)
This includes folder size changes.
Enabling will reduce the update performance of Everything.
Overquoting is evil! 👎
Re: The modified date of the folder reflects the changes in the modified dates of the subfolders
Yes, I didn't see either. And the author explained why:Fla$her wrote: 2024-08-19, 10:10 UTC You're welcome. I see the author responded to you by suggesting to enable the always_update_folder_recent_change=1 option, but I didn't see any date/size changes if you create something at depth 2 and below.
void wrote: When enabled, all parents to the root are updated for the Date Recently Changed property..
However, grand parents will only update when a child file size changes.