Solved

vbscript get file extension

Posted on 2009-04-06
1
16,508 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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now