For 100 databases it is neither easy nor fast. Moreover I want it to happen dynamically in script so manual intervention is out of question.

I just found a way using this simple sql select.

select substr(name,1,instr(name,'system')-1) from v$datafile where file#=1;

I forgot to mention I wanted to know the directory of the system datafile.

Anyway thanks for the help