Well, that is a different question, and the answer is probably "no"... Unless of course the files you're dealing with happen to be named (or arranged in directories) in such a way that their type can be determined reliably by the path/name.
But if directory structure and file names are not sufficient to know the type of file content, then there is simply no way to figure out the type of content without actually reading some of the content. And there you go -- you've read the file and spoiled the access date.
On some systems (and for super-users on other systems) it may be possible to reset the access date of a file -- that is, get the file age first, then read some content to find out what type of content it has, then reset the access date to it's prior value. You'll need to look it up for your particular OS.
update: Maybe I misunderstood your question: Is it important that the access date remain as it was after your script is completely done (e.g. to avoid certain consequences for other processes)? Or is it just a matter of wanting to know the how long ago the file was accessed before you try to test its content (i.e. it's okay for the file's access time to have changed after the script is done)?
If the latter, just put the stat operation for access date before you check for text vs. binary content.
In reply to Re^3: Getting the Access Date of a file without changing it
by graff
in thread Getting the Access Date of a file without changing it
by slloyd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |