mIRC Homepage
Posted By: Cyrex File Extension - 23/04/04 03:17 AM
How can I find out what file extension a specified file is?

I need to have my script check to see if the file a user selects is certain file type. If the file they select is not a file type my script supports, the script returns an error.
Posted By: spling Re: File Extension - 23/04/04 04:27 AM
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:
Code:
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 smile
Posted By: Iori Re: File Extension - 23/04/04 07:00 AM
Shorter version wink
set %FILE.EXT . $+ $gettok(%FILENAME,-1,46)
Same without the .dot
set %FILE.EXT $gettok(%FILENAME,-1,46)
Posted By: spling Re: File Extension - 24/04/04 09:25 AM
just showing me up all over wink
Posted By: Iori Re: File Extension - 24/04/04 10:46 AM
Nah don't think of it like that. Offering some constructive critisisms. grin
© mIRC Discussion Forums