Tuesday, February 20, 2007

Your WSH is my command, part 2

As I mentioned in part 1, the WSH and some VBScript can be used to do more than move files around. Another use is in parsing the data in files. Parsing text files is very easy to do, but there are no built-in functions for accessing binary data. You will find, however, that others have made up for this shortcoming by implementing their own classes for manipulating binary files. See for example this site with example code. This example uses only VBScript code to create a Binary Object class, although better performance is achieved using dll's or COM objects. However, for the purposes of my demonstration, I used the CBin.vbs code in the tsbin.zip file at the above site. If you would like to run my demo script, you will have to download this zip archive and put the CBin.vbs file in the same folder as the script when you run it. My example pulls a list of wav files from a given folder and reads the binary file header and prints out the CartChunk Content Depot data. One could use this information for making scripted decisions about when to copy or move files or perhaps to push the future XML pad information in the file to a database for a "Now Playing" or other application. Currently, I don't have any other good uses for this script besides reporting what is there, but maybe it is useful to you. Maybe you could use it to email someone when a new file shows up. I would love to hear some more ideas. So, without further ado, here is my code for your perusal.

ConDepReader_v1_0_1.zip

UPDATE (2/22/2007): After reading some posts on Pubtech lamenting the lack of a spreadsheet of CutIDs, I updated the script (now v1.0.1) to output a report of files and CutIDs in CSV format for use in Excel or whatever.

No comments: