I have a Linux machine with a large number of files in a huge directory tree, saved from another machine. The original files aren't available any longer.
Both files and directories have a last-modified time. You can see that a certain file was last modified in April 2004, or Jan 2001, etc. Directories also have last-modified times, which usually correspond with the date and time the most recent modification happened.
I have a problem with these directories I saved. The files I saved each have the correct modification date. The directories the files live in, though, all have the same timestamp, which is the day I saved all the files. It's difficult to sort through all those files chronologically if all the directories have the same modification date.
Does anyone know of a way to update a directories last-modification date to match the date of the most recent file in the directory? I know you can use 'touch' to set a date to 'now', so if I wanted to move the clock forward I could. Is there a way to move backward?
(Yes I have root on this box, so I can do any weird filesystem manipulation necessary. I suppose I could learn how to do this stuff with system calls and write my own program, but I've never done this before.)
I'm thinking either there's a program someone wrote (that I can't find, on freshmeat or sourceforge) or there's a built-in system tool I can use with a command line 'for' statement.
Anybody have any hints?
MEMBER OF THE PARANOIA GM GUILD
XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
QRZ || My last known GPS coordinates:
FindU or
APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
Posts
On my Ubuntu box, man time says:
-t STAMP
use [[CC]YY]MMDDhhmm[.ss] instead of current time
Also:
-r, --reference=FILE
use this file's times instead of current time
Let's not call this solved yet. I'm trying to come up with a series of bash commands that set the timestamp of a directory to the time of each of the files inside the directory. Many directories contain other directories, though, so we'd need to set the time of the deepest directories first, then the second deepest, etc. This directory tree is nine levels deep.
Since I don't think you can do recursion with bash commands, I'm working on a set of bash for statements that recurses into the deepest directories first, then the second deepest, etc. I'll post my statements if I can get this to work -- then we'll call this solved.
Not yet though.
XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
I'm not quite sure what you mean by not being able to do recursion with bash commands, but is this what you meant?
EDIT: Need to enable bbcode
This way it's setting the timestamp of the directory to the time of the last file in that directory. I'd rather it set the timestamp of the directory to the latest time of all files in that directory.
XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )