Solved

vbscript get file extension

Posted on 2009-04-06
1
18,657 Views
Last Modified: 2012-05-06
Hi guys was wondering if anyone knew why i cant get this code to run?
Cheers
Nathan
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "D:\"
 
Set objFolder = objFSO.GetFolder(objStartFolder)
Set objExtension = objFSO.GetExtensionName("D:/") 
Set colFiles = objFolder.Files
For Each objFile in colFiles
	If objExtension = "jpeg" then
    Wscript.Echo objFile.Name
	End if
Next

Open in new window

0
Comment
Question by:nathanlukewong
[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
1 Comment
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 24076720
Try the below code.

Wayne
     Set objfso = CreateObject("Scripting.FileSystemObject")
     objStartFolder = "D:\" 
     Set objFolder = objfso.GetFolder(objStartFolder)
     For Each objFile In objFolder.Files
          If objfso.GetExtensionName(objFile) = "jpeg" Then
               Wscript.Echo objFile.Name
          End If
     Next

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

695 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