Solved

vbscript get file extension

Posted on 2009-04-06
1
17,682 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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