Change folder modified to date as same to the files inside

Yes. This is an "interesting" design feature. Simply navigating to an NTFS folder, opening a file and closing without change, has the unfortunate side effect of updating the folder's time stamp. Like many others, I would dearly love to be able to switch this behaviour off but I expect we are stuck with it until something better comes along to supersede NTFS.

Regards, AB


Need your help mate.

As far as having a continuous loop of refreshing the folder dates, because file modified date is updated every time a file is clicked, it seems kinda distant to me.

Reason being I am requesting a script or routine which would be triggered manually, upon user request to perform the desired action. If the script is not called, it is not supposed to keep an automatic check of file timestamps and match the folder timestamps whenever an update is detected.

Still looking for it, is RegEx the answer...??? I dont know a clue about it anyways.


Was able to work my way by using the Windows Power Shell (built in Windows 7) or you can download otherwise as well.

The following script works for me (have tested it).

Get-ChildItem $root | Where-Object {$_.PSIsContainer} | Foreach-Object{

# get the oldest file for the current directory object
$oldest = Get-ChildItem $_.FullName | Sort-Object LastWriteTime | Select-Object LastWriteTime -Last 1

# oldest object found, set current directory LastWriteTime
$_ | Set-ItemProperty -Name CreationTime -Value $oldest.LastWriteTime 
$_ | Set-ItemProperty -Name LastWriteTime -Value $oldest.LastWriteTime
# current directory is empty, directory LastWriteTime is left unchanged
Write-Warning "Directory '$($_.FullName)' is empty, skiping..."

The compiled script is attached. Just download it and run it in the INTENDED root directory (with the target subfolders) in the Power Shell Console. It runs by .\date command in the powershell console.

It will update the "Created" and "Last Modified" date to the latest date of child objects (files inside) found inside each subfolder.

Try and post your results.


Hello All,

Have tried it with various folders having varied number of files inside. It is working correctly. The forum did not allow me to attach the compiled script (date.ps1). So trying to attach it in a ZIP file.

Just download it , copy and run it in the INTENDED root directory (with the target subfolders) in the Power Shell Console. It runs by ".\date" command in the powershell console.

Also posting and INF file, which would make the life easier for you by adding the shell context menu with an option to open PowerShell console in the subfolder. (Similar to having the 'Command Prompt here') . Just right click and install it, it would be active instantly, provided you are using Windows 7 and have the PowerShell installed at the default location.

There is one observation however, it is working only with the locally attached storage (USB, SATA, eSATA) harddisks. I have tried running it in a network mapped folder with all the write permissions, and the folder dates were not updated. Will keep trying for it, and will post the result.

Please give feedback here so it can be improved if needed.

Thanks. (741 Bytes) (453 Bytes)

Hey, thanks for your script. I just tested it both on Local and on a NAS and it worked. The difficulty is all the digital certificates. Once I set it to unrestricted in powershell, I could run it from the NAS. If you set the policy to remotesigned, it can not run it from a NAS. My next step would be to actually sign the script and set back the policy to restricted.

I have 2 more variant scenarios for your script.

1- One that would set the date to the newest file.
2- The second would be that it look for a specific file in each folder and use its date. Like a seen.txt in each folder.

Could you help me please here. I want for the script to look for a file name date_seen and change the folder timestamp to that.

I have replaced one line with this:

$oldest = Get-ChildItem $_.FullName | where-Object {$ -match "date_seen"}

this works, however if the folder name contains [] it doesn't and my folder names have these two characters in them.
Any ideas?

I just figured it out. Just add -literalPath and it ignores wildcards.

Also the original script sets the date to the newest file and not the oldest file.
Is it possible to do the same thing with DOpus scripts and make it easy?
Because with powershell you have the execution policy problem.


I know . . .

This is a very old thread, but, as for the request: same for me: Yes! It would be nice to have this available as a button, i.e. click on a folder, click on the button, done!
Have no idea about Powershell, it seems to be on my pc, guess I can start it, but then what ..?


I know this thread is old, but I would definitely +1 this feature request. A folder modified date with no correlation to the files inside has been a long-time pet peeve of mine -- annoying enough for me to register for the forum after being a user for 20+ years :slight_smile:

Thank you! I guess I should have asked sooner...

I also installed the alternative script (ColFolderDate.js.txt) and it offers column sorting by Oldest (Create) and (Modified), which is also helpful. Is there a recursive version of these? I am trying to find the oldest file within a subfolder as well as I organize my old photos.

It'd be fairly easy to modify my script to do that. Don't have time just at the minute, though.


No rush of course but certainly would appreciate it. Almost all of my old photos appear in folders from 2013 and I would love to sort them more accurately!

Thanks for the quick responses and on a weekend.

Globally replacing Newest with Oldest and < with > in Leo's script should be sufficient :slight_smile:


Up front I am not sure if this is what you are looking for, but FWIW I am using a small tool for this for I don't know how long. A toolbar button.
Select a (parent)folder, click on the button (or context menu item if you like) re-date the folder after the oldest newest file dates inside modified or created or both. When clicking on a parent folder with sub folders I can select 'Recurse' to take the oldest or newest date within any sub sub folder.

Below example - parentfolder "Change folder date after dates of files inside" with a few sub folders.
Folder date 11-06-2021
In some sub folder a file is dated 31-07-2021
Run SetFolDate to Newest, Recursive
Parentfolder date changed accordingly.
Obviously same goes for old date files (see 2)

Thanks, that worked! Beautiful.

That looks really handy, although I do not have that button in my list when I try to customize my toolbar. Is it available somewhere?

It is a tool that I am using for years. Basically you create a folder within Opus Program folder,

  • folder SetFolDate, then
  • extract attached zip + copy the contents to the SetFolDate-folder,
  • run the .exe (virusfree), it will create a .ouc file, that you can import to get a context menu item if you wish,
  • or you can create a toolbar button.

A pdf file is included how to proceed.
Note, there is a SetFolDateFM.in_ included. It is an .ini file. A few items are automatically selected then. Like always use Recurse and always apply changes to Modified and Created, so I don't need to tag those items each time. But that is optionally.
Also remember, the folder should be in the right window panel and selected of course. (1.1 MB)

SnagIt-16082021 153940

1 Like

If you go with changing the folder timestamps, instead of using a column which calculates the oldest/newest times on demand, note that:

  • The Modified timestamp on folders is fragile. As soon as anything adds, removes, or renames a file or folder directly below the folder, the folder's timestamp will be bumped to the current time. That's a function of Windows/NTFS and not something you can prevent.

  • (OTOH, editing a file in-place may or may not bump the folder timestamp, depending on how the program doing the editing works. And changes in sub-folders don't affect the parent folder's timestamp. So the Modified timestamp on a folder isn't useful as a "newest file/change" stamp either. Modified timestamps on folders are not useful for much on Windows.)

  • The Created timestamp is generally more stable, on the other hand. If you change it, it will usually stay that way, unless some software does something unusual.

  • You'll need to re-run the tool if things in or below the folder change that would affect the desired timestamp.

Can be useful if you know the folder contents are never going to change. Otherwise, a column that calculates what you want each time is going to work better and always display exactly what you want.

1 Like

I use this tool is some specific scenarios only. Like after synchronizing folders, or copy files into folders and wanting to re-establish the previous (old) folder dates so as to better distinguish old from new when going through folders.