Yes, you can.
The filename is on p_filename.
You can look at the file extension anthen choose the folder.
You can even change the filenemae if you need.
For example you can use the following code:
ext# = instring('.',p_filename,1,1)
ext" = choose(ext#>0,sub(p_filename,ext#,4),'')
case ext"
of 'jpg'
...
...
...
Hope this helps
Alberto