The behavior will depend on the type of file system. On classic Unix file systems (and in particular on the Mac OS X HFS file system), the interesting thing about renaming a file in the file system is that it does not affect the file inode at all; this only affects the directory (or directories) where the file was moved from / to. Thus, within the same file system, the only timestamps that change to rename are the time the directory containing the file was changed. For example, * :
$ fl -a -c -m -n xxx.pl 2013-07-17 16:17:17 2013-07-17 16:17:17 2013-07-17 16:17:17 xxx.pl $ mv xxx.pl yyy.pl $ fl -a -c -m -n yyy.pl 2013-07-17 16:17:17 2013-07-17 16:17:17 2013-07-17 16:17:17 yyy.pl $
This means that in such file systems you cannot determine when a file was renamed some time after the file was renamed.
* fl is the brew home team; the call is equivalent to calling Mac OS X stat stat -f '%Sa %Sm %Sc %N' . This is only slightly related to the GNU / Linux stat team.
Empirical evidence, on the other hand, shows that the Linux ext4 file system records the name change with the modification time of the inode itself.
$ stat -c '%x %y %z %n' test.dat 2013-07-19 10:31:31.803842672 -0700 2013-07-19 10:31:31.803842672 -0700 2013-07-19 10:31:31.803842672 -0700 test.dat $ mv test.dat test.data $ stat -c '%x %y %z %n' test.data 2013-07-19 10:31:31.803842672 -0700 2013-07-19 10:31:31.803842672 -0700 2013-07-22 09:11:49.074339525 -0700 test.data $
So what you can do depends on which one you are working on and which file system your file is typing.
If you have an inotify service available and running, you can record the event, which is the renaming of the file, but if you do not record the event, there is no way βposthumousβ to find out when the file was renamed.
Directory change time is not a good indicator of when a particular file was changed; It changes whenever any file is created, moved, deleted. If there is only one file in a directory, then the change time probably indicates when this file was created or renamed, but individual file directories are an exception, not a rule.