Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

trim extension when using fso

Posted on 2004-09-29
12
Medium Priority
?
437 Views
Last Modified: 2010-05-18
I am using FSO to build a dynamic list/menu with the file name from my folder.

What I would like to do is display the file name without the extension in the list/menu.

A bit of what I am using:

<%For Each objFile In objFolder.Files
          arr = split(objFile.Name, ".") 'split the name and the extension into an array
          If (arr(UBound(arr)) = "wma") then
                  response.Write("<option value=""mms://myStreamURL.ath.cx" & objFile.Name & """>" & objFile.Name & "</option>")                
          End If
     Next

Think this is an easy one, just lots of point cuz I'm lazy and in a hurry ;)

Thanks!
0
Comment
Question by:nickleplated
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +1
12 Comments
 
LVL 19

Expert Comment

by:Shauli
ID: 12180268
Left(objFile.Name, Len(objFile.Name)-4)

S
0
 
LVL 19

Expert Comment

by:Shauli
ID: 12180298
Which means that you dont need to split. However, if you do want to split, then arr(0) would contain the name and arr(1) would contain the extension.

S
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 12180314
You use UBound to get the extension so LBound should give you the name

cheers


Scott
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Assisted Solution

by:Shauli
Shauli earned 1600 total points
ID: 12180339
Or with your text (Split option)

          arr = split(objFile.Name, ".") 'split the name and the extension into an array
          If (arr(1) = "wma") then
                  response.Write("<option value=""mms://myStreamURL.ath.cx" & arr(0) & """>" & arr(0) & "</option>")                
          End If

Left option:

          If Right( objFile.Name, 3) = "wma" then
                  response.Write("<option value=""mms://myStreamURL.ath.cx" &  Left(objFile.Name, Len(objFile.Name)-4) & """>" &  Left(objFile.Name, Len(objFile.Name)-4) & "</option>")                
          End If

S
0
 
LVL 1

Author Comment

by:nickleplated
ID: 12180344
ok - so I have:

<%For Each objFile In objFolder.Files
 
          arr = split(objFile.Name, ".") 'split the name and the extension into an array
          If (arr(UBound(arr)) = "wma") then
             
                  response.Write("<option value=""mms://myStreamURL.ath.cx/" & objFile.Name & """>" & Left(objFile.Name, Len(objFile.Name)-4) & "</option>")                
          End If
     Next
       %>

Which seems to work perfectly.
I was doing the split to make sure that it only gave me "wma" files // for obvious reasons.

Is there a tighter way to achieve this?

Thanks for the fast responses!
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12180369
oFSO.GetBaseName(objFile.Name)

where oFSO is
dim oFSO as FileSystemObject
0
 
LVL 1

Author Comment

by:nickleplated
ID: 12180373
let me add something?

Some files may contain additional "."

ie:
AFRICANISM.MIXED.BY.BOB.SINCLAR.wma
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12180384
If oFSO.GetExtensionName(objFile.Name) ="wma" Then
0
 
LVL 19

Expert Comment

by:Shauli
ID: 12180390
If you split, then use the lbound, which contain the name without the extenstion:

response.Write("<option value=""mms://myStreamURL.ath.cx/" & objFile.Name & """>" & arr(0) & "</option>")  

S
   
0
 
LVL 19

Expert Comment

by:Shauli
ID: 12180412
See above, nickleplated , the LBOUND contains the name, the UBOUND contain the extenstion. Which means that arr(0) is the name without the extenstion, nomatter how many dots you have.

S
0
 
LVL 8

Accepted Solution

by:
mladenovicz earned 400 total points
ID: 12180416
GetBaseName will work with additional dots and if extension length is less than 3 chars
0
 
LVL 1

Author Comment

by:nickleplated
ID: 12180559
Thanks to all, below (IMHO) seems the tightest

<%For Each objFile In objFolder.Files  
           arr = split(objFile.Name, ".") 'split the name and the extension into an array
          If (arr(1) = "wma") then
                  response.Write("<option value=""mms://myStreamURL/" & objFile.Name & """>" & arr(0) & "</option>")
          End If
     Next
%>

Cheers to all.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question