Without some external calls you're never really going to have a satisfactory conclusion to this. The algorithm to convert it is fairly straightforward (remove illegal characters, take leftmost resulting six characters, add a tilda and a '1' followed by the original file extension.
The problem is that many different long filenames resolve to identical short file names so you need to test for existence of the short filename and start incrementing the final '1'. To test for the existence of the file you would need Extproc or Java calls.
The problem occurs much later on when you have successfully changed....
'oraclefilea.sql' to 'oracle~1.sql'
'oraclefileb.sql' to 'oracle~2.sql'
and you are left with just the resulting short name.... which one relates to which original long name? You would need to manage this somewhere.
Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.