It wold help if you gave more details on the script..
I haven't thoroughly tested this, but let's say your filename was in the %FILENAME variable...
this will put the extension in the %FILE.EXT variable:
set %FILE.EXT $right(%FILENAME,$calc($len(%FILENAME)-$pos(%FILENAME,.,$count(%FILENAME,.))+1))
It will also work for file extension longer or shorter than 3 characters, and files that are like :"little.bown.happy.dog.gif"
Hope that works for you