Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - Reading MP3 ID3 Tags in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Reading MP3 ID3 Tags in WSH
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-09-24

    Table of Contents:
  • Reading MP3 ID3 Tags in WSH
  • Retrieving file details in WSH
  • Constructing the Script
  • Working with the Data

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Reading MP3 ID3 Tags in WSH - Retrieving file details in WSH


    (Page 2 of 4 )

    As I mentioned, we’re going to rely on the Windows Shell and its scripting interface for retrieving the information we want.  I’m going to tell you the column numbers you need to use later in this article, but for learning purposes, let’s see how I was able to find them.

    strFolder = "C:Documents and SettingsNilpoMy DocumentsMy Music"

    We begin our script by creating the variable strFolder and setting it to a folder path containing MP3 files.

    Set objShell = CreateObject("Shell.Application")

    Set objFolder = objShell.NameSpace(strFolder)

    Next we connect to the Windows Shell object and use its NameSpace method to return a folder object.

    object.GetDetailsOf(file, colId)

    The Folder object has a GetDetailsOf method that allows us to read the details of files within a folder. It has two required parameters where file is a reference to a File object within the folder and colId is an integer representing the detail column to read.

    Ordinarily, at this point we would use the Folder object’s Items property to return a collection of File objects and then iterate through them, reading the respective details; but as it turns out, if you provide a non-existent object, you can return the actual column headings instead.

    For N = 0 To 100

       WScript.Echo N & vbTab & objFolder.GetDetailsOf(Nothing, N)

    Next

    Depending upon your system and the types of files contained in the folder, there can be well over one hundred different file properties available. For our purposes we’re only going to look at the first one hundred.

    Here, I’m using a simple For…Next loop count from 0 to 100. Notice that I’ve used the Nothing keyword in place of a File object in the first parameter. Remember that VBScript uses the Nothing keyword to represent a disconnected or invalid object reference.

    Running the script will return a list of all of the column headings for columns 0 through 100.  You can run this script on your own if you’re curious about the different details that are available, but I’ve included a table below with the ones that we are interested in.

    Windows XP and Windows Server 2003 use the same column IDs while Vista has its own renumbering. Some of these fields are also available on Windows 2000 and earlier; however, they may not include all of them.

    Tag Name

    Windows XP and
    Windows Server 2003

    Windows Vista

    Name

    0

    0

    Size

    1

    1

    Type

    2

    2

    Title

    10

    21

    Comments

    14

    24

    Artist

    16

    13

    Album Title

    17

    14

    Year

    18

    15

    Track Number

    19

    27

    Genre

    20

    16

    Duration

    21

    36

    Bit Rate

    22

    28

    More Windows Scripting Articles
    More By Nilpo


       · Did you know that you can use WSH and the Windows Shell object to read the ID3...
       · What would be really usefull is a way to be able to add more tabs on the columns in...
       · There are some third-party ActiveX components available that can do this.
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT