[TriEmbed] Repair Folder Dates with Single-line Windows PowerShell Script

Shane Trent shanedtrent at gmail.com
Fri Aug 29 08:55:52 CDT 2014


Hello,

I would like to get feedback on a write-up that I just finished. Next week
I hope to figure out how to cross-post it to the Triembed page.

A DropBox glitch resulted in a rollback that reset all of my folder
modification dates. I wrote a single-line script in Windows PowerShell to
scan a target folder and set the date of every folder to the modification
date of the newest file in the folder or sub-folder. The script could be a
little shorter but I want it to work in PowerShell 1.0 since this version
is installed by default on millions of Windows PC's. Here is the
single-line.

Get-ChildItem "H:\DropBox\FolderDateFix\Test1" -recurse | Where-Object
{$_.PsIsContainer} | ForEach-Object {$_.LastWriteTime = ($_ | Get-ChildItem
-recurse | Where-Object {!$_.PsIsContainer} | Sort-Object LastWriteTime |
Select-Object -last 1).LastWriteTime}

Here is my post where I walk through how the script works.
http://fettricks.blogspot.com/2014/08/useful-folder-modification-dates-via.html

Thanks,
Shane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20140829/f86c17f7/attachment.htm>


More information about the TriEmbed mailing list