retrieve extension of a variable that come from a file

Hello we have in vbscript some coding to grab file names from directories and put in a dynamic variable that change frequent. Now from that variable we want to put in another variable the extension only of what it was the file that now is a variable. For example we have a variable called "filenamecomplete", this is the variable where the vbscript store the name of the filename grabbed, and we want in the variable "resultingextension" store the extension of that variable that originally was a file name. Look these examples with some value examples of "filenamecomplete" and what we want to store in "resultingextension":

filenamecomplete (string var. value   resultingextension (variable to store extension)
example)      


filename.doc                                                 .doc
filename.fil.doc.                                            .doc
filename.fil.docx                                           .docx
filenamefile.file.file.aa.dd.ff.dddms          .ddms
filename.ff.dd.ww.exteneioep                   .exteneioep

   Like you see sometimes could be extensions longer than 3 and 4 characters and could be "." characters in different positions of the string "filenamecomplete".

   Someone could help with an example vbscript code to reach this result?
   The vbscript code is of course to use in a normal ".asp" file, we don't use ASP.NET, just simply ASP and to put the code in the middle of a normal call of vbscript in ASP files, in other words put the code in the middle of:

<%

put code here

%>

Thank you so much
coerraceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
stringSize = len(filenamecomplete)
x =InStrRev(filenamecomplete,".")
extensionSize = stringSize - x
resultingextension = right(filenamecomplete,extensionSize)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
You can do it with one line of code:

FileNameComplete = Right( fileName, InStrRev( fileName, ".") - 1)
0
coerraceAuthor Commented:
Works perfect.
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.