When using scripting to compile files and run simulation it should be possible to check if a file has changed since last time it was compiled or if it is infact a different file with the same name. In both cases, the file must be compiled again. Otherwise, it should not be compiled.
How do I do this in QuestaSim/Modelsim?
Also, by the way, what is the difference between a .do file and .tcl file in QuestaSim/Modelsim?
If you have a script than invokes vcom - then you are forcing a recompile. You could write some tcl to check timestamps, but it could be rather involved.
You may be able to use a make file as sherif123 suggested, but I never do.
There is an incremental flag of some sort that limits a full compile but I don't recommend using it. I recall back in the days we would regularly have to delete the work directory to fix unexplaind problems during compilation. Many of them turned out to be a corrupted work library. Deleteing it and recompiling would fix the problem and we eventually found out it was caused by that incremental switch.
Using a make file is the way to go, but it's not something I use.