Windows utility to modify modification date.
January 8, 2004 3:31 PM   Subscribe

I'm looking for a Windows utility that will recurse through a series of subdirectories and change the modification date on each folder to be the same as the newest item in that folder. [More inside]

This is something that has eluded me for a long time now. I like to keep my folders sorted by date. I just think and work best that way. But there are a lot of things that can happen to change the date of a folder undesirably. The most obvious is moving folders from one machine to another: they all end up with the current date, instead of the date they had on the original machine. Another case is when you go into a two-year old directory and delete something: BAM! Now it's got today's date, even though everything in the folder is still two years old. Very frustrating.

I've Googled and I've searched through all my usual sources of freeware/shareware (nonags.com, tucows, webattack, pricelessware, betanews) and I've found lots of utilities (dozens!) that will let you set the date/timestamp to a particular, specified, value, but doing that manually on dozens or hundreds of subfolders would be a major pain. Is there some utility that will do it for me automagically?

(Freeware would be nice, but shareware is fine too. Either GUI or command-line is fine; I'm not picky, as long as it runs on 2000/XP.)
posted by llamateur to Computers & Internet (8 answers total)
 
I think you might find AttributeMagic useful. I haven't used it myself, but it does have a free trial.
posted by monju_bosatsu at 4:00 PM on January 8, 2004


Thanks, but that's one of the ones that I've tried, along with Attribute Changer (which is really nice and is freeware), Attribute Manager, and lots of others.

None of those seemed to do what I described above (unless I was just unable to find the feature.) One had a promising feature called "Date and time synchronization" which I thought might have been it, but that just turned out to keep the three dates (modification, creation, and access) synchronized with each other.
posted by llamateur at 4:10 PM on January 8, 2004


This might be a good starting point if you want to roll your own.
posted by littlegreenlights at 4:49 PM on January 8, 2004


That's a weird need, I bet you're best off just writing a window shell script or bat file using dos commands of some sort.
posted by mathowie at 5:07 PM on January 8, 2004


cygwin is a nice unix-type environment for windows machines. it's a small skip and jump from there to a quick perl or shell script to do this.
posted by lescour at 5:30 PM on January 8, 2004


Okay, well I've taken the advice of mathowie and lescour and hacked together some really ugly .bat files, using a bunch of nested FORs and stuff, along with a command-line attribute changing utility that I found (FileTouch). It's not pretty, but it did successfully do the job for the one big directory (with 200 subdirectories) that I most wanted to clean up.

But I'd still be interested in hearing from anyone who comes along later and happens to know of any utilities that already do this (and which would undoubtedly be more robust than this non-programmer's hack), so please let me know.

And thanks, littlegreenlights. I didn't know about forfiles! (I ended up using for /r for this, because it was just a better fit for the job in this case, but I bet I'll be using forfiles for other things in the future.)
posted by llamateur at 8:26 PM on January 8, 2004


Congrats on making your own tool--must feel great! I gave it a shot but I'm a batch file amateur and had problems with the 'determining the newest file automatically' part.

This is probably too late to be of any use, but for perpetuity's sake I'll post it. I was browsing around and found and installed 12Ghosts FileDate which would seem to do what you require, except for, again, the whole figuring out which file is the newest thing. (It has a command-line interface in addition to the GUI, though, so it seems like that could be managed.)
posted by littlegreenlights at 8:53 AM on January 9, 2004


Well, there are two ways I thought of to find the newest file. The first is simpler and would work if there weren't nested subfolders, which is using a FOR command wrapped around a DIR /OD command. DIR /OD sorts by date, and the FOR command runs through the output of the command and sets a variable for each line. When it's done, the variable will be set to the last file listed, which would be the newest one. So that would look something like:

for /f %%i in ('dir /od') do set newest=%%i

(Although you'd need a few more tweaks in there to make sure you're just pulling the date, and none of the rest of the info that dir returns.)

In my case, I wanted it to recurse through the subdirectories and find the newest file that exists anywhere in the tree, so I used for /r (which by default only returns information about files, not folders, which is why I used it rather than forfiles) and then piped that output through the sort command. (I also had to rearrange the month day year into year-month-day so that the sort would work properly.) So the command to find the newest ended up looking like this:

(for /f "tokens=1,2,3 delims=/ " %%j in ('for /r %1 %%i in (*^^) do @echo %%~ti'^) do @echo %%l-%%j-%%k) |sort

That returns a sorted list of just the filedates, again with the last one being the newest. So then i had another batch file which did the same thing I described above: go through that output line-by-line setting a variable each time, with the last one being the one it uses:

for /f "usebackq tokens=1,2,3 delims=- " %%m in (`findnewest.bat %1`) do set newdirdate=%%n-%%o-%%m

Then it just calls the attribute changing program with that info. (I may check out the 12Ghosts one, in case it's any better than the one I'm using.)

Anyway, quite a mess, but workable (And fortunately not nearly as slow as you might think.)
posted by llamateur at 9:33 AM on January 9, 2004


« Older How to kill three hours on campus?   |   A DVD codec for Win2K? Newer »
This thread is closed to new comments.