Thursday, December 15, 2005

Dating Design Patterns

I have been spending a lot of time looking into various software design patterns, so when I saw this on Thinkgeek.com I couldn’t help but laugh.

Christmas is almost here. What a great gift for your single geek friends.

Web Messenger

I did not know there was a web version of MSN Messenger. It doesn’t have everything that the desktop version has (it only focuses on chat) but if your company has blocked the MSN Messenger ports this is a great work around.

Actually the company that I work for blocked this site but didn't block the MSN Messenger ports.

Chat on!

Thursday, December 01, 2005

IM the Encarta Server

I saw this on Chris Sells' blog. What you do is add encarta@conversagent.com to your MSN IM contract list and then you can chat with the Encarta server by asking it questions. The questions are somewhat limiting, however the idea of chatting with a computer is very interesting. Being that you are using an application that is primarily used to communicate with humans, this has an AI feel to it. It is very cool.

Example Questions:

  • What is the population of the earth?
  • Solve x+2=5

Monday, November 21, 2005

On the Effectiveness of Aluminium Foil Helmets

I thought this was good.

The funnies thing is that the first picture (of Ali Rahimi) looks just like one of the guys that I work with.

Monday, November 07, 2005

Application Response Time

I was listening to a podcast interview with Joel Spolsky and the interviewer mentioned a quote that I thought was quite good. He quoted Jacob Nelson (I hope I got that correct).

“If the application responds in a 10th of a second, then you feel like you are in control. If the application responds in a second, then you feel like you are being controlled. And if the application responds in 10 seconds, then it is broken.”

BTW: Joel had some interesting ideas on Ajax and Web 2.0.

Wednesday, October 19, 2005

Silicon Art

This is really cool. Over at Silicon Zone you can find some images found on processors.

I find it amazing how small these things are, you have to use a high powered-microscope just to see it. Even more amazing is the fact that chip builders would put these images on processors in the first place.


Daffy Duck

Where’s Waldo?

Tasmanian Devil

The Space Shuttle

Dilbert

Monday, October 10, 2005

External Hard Drive

After a couple of hard-drive failures I decided to get an external hard drive. I bought an external Coolmax CD-310-U2 series. It does not come with a hard drive but instead allows you to put your own hard drive in it. It connects to your computer via a USB connection. Being a hard drive junky, I like to have a couple of hard drives kicking around that hold my data. You can use any 3.5” IDE HDD (ATA66/100/133). (It does NOT support SATA hard drives.) It is quite easy to setup, all you do is plug in a formatted hard drive (set to master or default) into the case then close up the case and you are up and running. I then downloaded SyncToy for Windows XP and am using that to synchronize directories from my computer to the external hard drive. SyncToy was originally created to synchronize pictures across different machines. The only thing that I found that I wish it supported was the ability to synchronize just the files in a directory without scanning the subdirectories. So if you have files in you’re My Documents directory that you want synchronized, you have to synchronize the entire My Documents directory and subdirectories or copy the files to another folder. I ended up copying the files to a My Docs folder under My Documents. This is a little annoying but doable.

Thursday, September 01, 2005

Microsoft LogParser

Coding Horror had a write up on the Microsoft LogParser. LogParser is an application that you can download and run via the command-line (there is also a COM DLL that you can use). You can write queries against the event log, the registry, CSV files, etc.

I downloaded it and gave it a try. Here is a walk through of a test that I did to query a CSV file(s).

The Test

I created a file called Test.csv that contains the following:

TimeStamp, MessageType, Message
2004-03-14 18:56:55, Warning, One
2004-03-14 14:02:23, Information, Two
2004-03-14 14:02:23, Information, Three
2004-03-14 12:00:00, Information, Four
2004-03-14 00:41:47, Warning, Five
2004-03-13 22:17:00, Information, Six
2004-03-13 22:06:48, Information, Seven
2004-03-13 22:06:48, Error, Eight
2004-03-13 12:00:00, Information, Nine
2004-03-12 22:30:47, Information, Ten

I saved the file to the C:\ and then from the command-line I did the following:

C:\Program Files\Log Parser 2.2>logparser "Select * from c:\test.csv"

The result of that was the following:

Filename RowNumber TimeStamp MessageType Message
----------- --------- ------------------- ----------- -------
c:\Test.csv 2 2004-03-14 18:56:55 Warning One
c:\Test.csv 3 2004-03-14 14:02:23 Information Two
c:\Test.csv 4 2004-03-14 14:02:23 Information Three
c:\Test.csv 5 2004-03-14 12:00:00 Information Four
c:\Test.csv 6 2004-03-14 00:41:47 Warning Five
c:\Test.csv 7 2004-03-13 22:17:00 Information Six
c:\Test.csv 8 2004-03-13 22:06:48 Information Seven
c:\Test.csv 9 2004-03-13 22:06:48 Error Eight
c:\Test.csv 10 2004-03-13 12:00:00 Information Nine
c:\Test.csv 11 2004-03-12 22:30:47 Information Ten

Statistics:
-----------
Elements processed: 10
Elements output: 10
Execution time: 0.00 seconds

I then copied the Test.csv file, creating "Copy of Test.csv", and ran the following:

C:\Program Files\Log Parser 2.2>logparser "Select Filename, TimeStamp, MessageType, Message from C:\*.csv where messageType ='Warning'"

The result of that was the following:

Filename TimeStamp MessageType Message
------------------- ------------------- ----------- -------
c:\Copy of Test.csv 2004-03-14 18:56:55 Warning One
c:\Copy of Test.csv 2004-03-14 00:41:47 Warning Five
c:\Test.csv 2004-03-14 18:56:55 Warning One
c:\Test.csv 2004-03-14 00:41:47 Warning Five

Statistics:
-----------
Elements processed: 20
Elements output: 4
Execution time: 0.02 seconds

Conclusion

The idea of being able to query a directory of files is cool.

There is a lot more to LogParser so download it an give it a try.

I also found an artical on using the LogParser DLL in a VBScript "All You Need is Log (Well, Log Parser)".

Thursday, August 25, 2005

Floating-Point Numbers

I have been working with floating-point numbers. Floating-point numbers are not exact in computers, they are numbers that closely represent a decimal number.

See the following URL’s for more information floating-point numbers.
www.lahey.com/float.htm
www.codeproject.com/dotnet/ExtremeFloatingPoint1.asp
www2.hursley.ibm.com/decimal/decifaq1.html

Here are some things that I found quite surprising.

1) In Microsoft Excel, enter the following into a cell.

=(0.5 - 0.4 - 0.1)

The result should be 0, however it is actually -2.77556E-17.

2) I created a C# windows applications and dropped a button onto the form and then added the following code to the button’s click event.

double f = Convert.ToDouble("1000000000.12345678901");
MessageBox.Show(f.ToString("0.0000000000000000"));
f = f - 1000000000;
MessageBox.Show(f.ToString("0.0000000000000000"));

When you run the application you will get the following message boxes:

1) 1000000000.1234600000000000
2) 0.1234568357467650

You would expect that the number displayed in the second message box would be 0.12346 because that is what the fractional part is after the initial assignment of the f variable. But it turns out that after you subtract 1 billion, something happens to cause the numbers at the end to appear.

Wednesday, August 17, 2005

Geek Joke

I read this awhile ago. And, the more I think about it, the funnier it becomes. It is funny because it’s true. Then, if you step back from it, it is just plain funny and clever.

From Coding Horror:

A Software Engineer, a Hardware Engineer and a Departmental Manager were on their way to a meeting in Switzerland. They were driving down a steep mountain road when suddenly the brakes on their car failed. The car careened almost out of control down the road, bouncing off the crash barriers, until it miraculously ground to a halt, scraping along the mountainside. The car's occupants, shaken but unhurt, now had a problem: they were stuck halfway down a mountain in a car with no brakes. What were they to do?
"I know", said the Departmental Manager, "Let's have a meeting, propose a Vision, formulate a Mission Statement, define some Goals, and by a process of Continuous Improvement find a solution to the Critical Problems, and we can be on our way."
"No, no", said the Hardware Engineer, "That will take far too long, and besides, that method has never worked before. I've got my Swiss Army knife with me, and in no time at all I can strip down the car's braking system, isolate the fault, fix it, and we can be on our way."
"Well", said the Software Engineer, "Before we do anything, I think we should push the car back up the road and see if it happens again."

Sunday, August 07, 2005

Mashups

I have been listing to some Mashups from www.MashupTown.com. These are awesome peaces of arts. If you have never listened to a Mashups before check out some of my favorites listed below.

Gotta Make Betty Sweat
Sharp dressed party
Bootystition
Spending one of these nights with Kelly
Stairway to Bootleg Heaven

Wednesday, June 08, 2005

VBScript - Add a file to iTunes

Rab dropped a comment on my iPodder VBScript(Copy New PodCast to My SD Card) post with an example of how to adding a file to iTunes. After looking at his script, I thought it might be cool to see if I could create a Playlist in iTunes and then add the file.

001 ' Variables
002 dim iTunes, FullPath, playlist
003
004 FullPath = "C:\Music\Machups\wewillrockbeverlyhills.mp3"
005
006 ' Connect to iTunes app
007 set iTunes = CreateObject("iTunes.Application.1")
008
009 ' Create playlist
010 set playlist = iTunes.LibrarySource.Playlists.ItemByName("My Test")
011 if playlist is Nothing then
012 iTunes.CreatePlaylist("My Test")
013 set playlist = iTunes.LibrarySource.Playlists.ItemByName("My Test")
014 end if
015
016 ' Add file to playlist
017 playlist.AddFile(FullPath)
018
019 set iTunes = Nothing
020 set playlist = Nothing


Line 10 tries to get a reference to a Playlist called “My Test”. If the Playlist does not exist the playlist variable will be Nothing. If the playlist variable is Nothing, “My Test” Playlist will be created (line 12) and on line 13 the playlist variable will get a reference to the newly created Playlist. Then on line 17 the mp3 file is added to that Playlist.

Friday, June 03, 2005

Google-fu

There are some great Google commands over at Coding Horror. (I keep going back to this page, maybe because of the Ninja.)

Also, Engadget has a cool article on how to customize a Google map.

Friday, April 29, 2005

The Long Tail

If you have not seen Chris Anderson's artical The Long Tail in Wired Magazine, it is worth a read. It is about how buying and selling books, music and movies has changed (and is changing) with the internet.

Tuesday, April 19, 2005

TaskList

TaskList is a cool command-line Windows XP command that can tell you additional information about processes that are running on your machine. I happened across this when I was looking for what the svchost.exe does. (You may have seen this in your “Windows Task Manager”.) svchost.exe runs services on your machine and to see what services are running enter the following at the command prompt.

tasklist /svc

Actually the /svc will display all the services for all the running processes and if the process isn’t running a service it will display “N/A”. If you only want to look at the svchost.exe process you can use the /fi switch.

tasklist /svc /fi "IMAGENAME eq svchost.exe"

IMAGENAME is the name of the column that you would like to filter (IMAGENAME is actually the process exe name). eq stands for equals and svchost.exe is the value.

Another useful switch is the /m. This will display all the DLL’s that are loaded for each of the running processes. Enter the following at the command prompt.

tasklist /m

To see a list of all the processes that have a specific DLL loaded you can enter the following.

tasklist /m netapi*

This will display all the processes that are running with the netapi32.dll loaded. (“*” is a wildcard. You can type out netapi32.dll if you like.)

For more help on this command you can use the /? switch. Enter the following at the command prompt to see more information on using the tasklist command.

tasklist /?

Thursday, April 07, 2005

Will monkeys replace programmers?

As I was pondering and Googling this, I came across the term “Code Monkey”.

Wikipedia's definition - "Amateur computer programmer who stiches together snippets of code found on the internet and in books and puts them together to make an application, without having an appreciation or understanding what the principles behind the code or the concept of coding are."

Another Wiki definition - (down on the page) "Rather than an insult for a programmer who is sloppy (which the above implies), I hear it used for someone who is doomed to work on "unglamorous" programming tasks, often using older/antiquated/"uncool" technology. Examples of work that a CodeMonkey might do in this definition (I do not intend to denigrate these tasks myself)" (hmm... Maybe I am a code monkey)

I also thought this was good (also from the wiki site above):

“If an infinite number of monkeys on an infinite number of type-writers randomly tap the keys, would they eventually produce Hamlet? And would they eventually be able to produce {insert your favorite program}?”

I also found this funny fictional story about monkeys on strike at Fox Broadcasting.
Monkeys NOT Working Around the Clock, On Strike

Tuesday, March 29, 2005

GMail Drive

I have installed the GMail Drive. This is really cool if you have multiple computers at multiple locations (not on the same network). It is really handy to have a internet drive. And using your free GMail account is a great idea.

Hmm… I wonder if someone will create a Hotmail Drive?

Thursday, February 24, 2005

Linux fan concedes Microsoft is more secure

This is very interesting. What next, will people say that Microsoft is more stable?

Monday, February 07, 2005

Values of a Great Programmer

What are the values of a great programmer?

Laziness, Impatience, and Hubris.


Read the Brad Appleton's Wiki post
Read Dan Miser's Thoughts

Monday, January 24, 2005

Another iPodder VBScript (Delete Old PodCasts)

Another management problem with iPodder is clearing out old PodCasts. And I have another VBScript file that can help manage this problem as well.

The following script will scan the files in your iTunes looking for iPodder files that are a week old and HAVE been played. Also, because you may run across a PodCast that you would like to keep, I have added and additional check on the Rating column. If you would like to keep a PodCast just set the rating to something other then “None”.

To run the iDelOldPodCasts.vbs script you can just double click it. Or if you want to run it with the –S command line variable you will have to create a batch file or a shortcut.

My apologies for the formatting. (Formated)

001 '-----------------------------------------------------------------------------------
002 ' This is a script file that will delete old PodCasts. This works with iPodder that
003 ' downloads files to your "My Documents\My Received Podcasts" directory. The files
004 ' in your iTunes library will be scanned looking for files that have been played
005 ' and the “Last Played” date must be older than seven days and the rating must be 0
006 ' (This will not delete old files that have ratings). You will be prompted to delete
007 ' the files. If no files where found you will get a message telling you that no
008 ' files where found. You can use the –S command line argument so that all files
009 ' will be deleted without being prompted, otherwise you will be prompted for each
010 ' file.
011 '
012 ' By: Richard Todosichuk
013 ' rtodosic@hotmail.com
014 '-----------------------------------------------------------------------------------
015 Option Explicit
016
017 Dim fso ' Scripting.FileSystemObject object used to copy files.
018 Dim Shell ' WScript.Shell object used to access information about the windows shell.
019 Dim args ' The command line argurments.
020 Dim arg ' A command line argurment.
021 Dim iTunesApp ' iTunes.Application object used to access the iTunes application.
022 Dim mainLibrary ' The iTunes Library object.
023 Dim tracks ' The tracks collection object of the Library object.
024 Dim currTrack ' The current track object from the Library in iTunes.
025 Dim TestDate ' Now minus seven days.
026 Dim PodCastDir ' The iPodder root download directory.
027 Dim FileList ' The list of files that have been copied.
028 Dim PromptVal ' The value of the message box for whether to delete the file or not.
029 Dim SilentFlag ' Command line flag that if set will not prompt the use to delete the file.
030 Dim i ' A counter variable.
031
032 Set args = WScript.Arguments
033 Set fso = CreateObject("Scripting.FileSystemObject")
034 Set Shell = CreateObject("WScript.Shell")
035 Set iTunesApp = CreateObject("iTunes.Application.1")
036 Set mainLibrary = iTunesApp.LibraryPlaylist
037 Set tracks = mainLibrary.Tracks
038
039 TestDate = (Date - 7)
040 PodCastDir = Shell.SpecialFolders("MyDocuments") & "\My Received Podcasts\"
041 FileList = ""
042 SilentFlag = False
043
044 ' Scan command line arguments
045 For Each arg in args
046 ' Is it a flag.
047 If Instr(1, arg, "-", 1) = 1 or Instr(1, arg, "/", 1) = 1 Then
048 ' Check for list flag
049 If UCase(arg) = "-S" or UCase(arg) = "/S" then
050 SilentFlag = True
051 End If
052 End If
053 Next
054
055 PromptVal = MsgBox ("Delete all PodCasts that are a week old." _
056 & chr(13) & chr(10) & chr(13) & chr(10) & "Continue?", vbYesNo + vbQuestion, "Delete PodCasts")
057
058 If PromptVal = 6 then
059
060 i = tracks.Count
061
062 While i > 0
063 Set currTrack = tracks.Item(i)
064 If currTrack.Kind = 1 AND _
065 currTrack.PlayedDate <> 0 AND _
066 currTrack.DateAdded <>
067 currTrack.Rating = 0 AND _
068 currTrack.Location <> "" Then
069 If Instr(1, currTrack.Location, PodCastDir, 1) > 0 Then
070 If SilentFlag then
071 'Delete files
072 If (fso.FileExists(currTrack.Location)) Then
073 fso.DeleteFile(currTrack.Location)
074 End If
075 currTrack.Delete
076 Else
077 PromptVal = MsgBox ("Delete file " & currTrack.Location & "?", vbYesNo + vbQuestion, "Delete PodCast")
078
079 If PromptVal = 6 then
080 'Build msg of all files
081 If FileList <> "" Then
082 FileList = FileList & chr(13) & chr(10) & currTrack.Location
083 Else
084 FileList = currTrack.Location
085 End If
086
087 'Delete files
088 If (fso.FileExists(currTrack.Location)) Then
089 fso.DeleteFile(currTrack.Location)
090 End If
091 currTrack.Delete
092 End If
093 End If
094 End If
095 End If
096 i = i - 1
097 WEnd
098
099 If FileList = "" Then
100 WScript.Echo "No files where deleted!"
101 Else
102 WSCript.Echo "The following files have been deleted:" & chr(13) &amp;amp;amp;amp; chr(10) & chr(13) & chr(10) & FileList
103 End If
104
105 End IF


(Download iDelOldPodCasts.vbs)

The code is not that complicated. Lines 45 to 53 handle searching the command line arguments that were passed into the script. Line 62 starts the loop that loops through all of the tracks in iTunes. Line 64 to 69 tests the track to see if it is in fact a file, the “Last Played” column is not blank, the “Date Added” column is older the seven days, the “Rating” column is blank, and the file is in the iPodder download directory. Then line 72 to 75 performs the delete without the prompt if –S was passed into that command line argument. And lines 77 to 85 will prompt you to delete the file and lines 88 to 91 perform the delete. After all of the tracks have been tested lines 99 to 103 will handle telling you either no files have been deleted or will display a list of all of the deleted files.

I should also mention that if you are running McAfee or other virus scanners this script may not work. Virus scanner writers like to re-implement the windows system Scripting.FileSystemObject and WScript.Shell objects. You can re-register the original windows COM objects and this will work fine. However, you should be aware that these files have been re-implemented for a reason. I don’t mean to scare people away from doing this but I mention this for two reasons. First I spent hours trying to figure out why things would not work and I don’t what you to do the same. Furthermore, if you have other virus scanners and spyware installed, you may be in luck. Better (well more script friendly) virus scanners and spyware software will detect that you are trying to run these objects and will prompt you to make sure that you really want to run them. This is a good approach. This will allow you to run VBScript files in a secure way. So, you CAN have your scripts and execute them too.

Friday, January 21, 2005

iPodder VBScript (Copy New PodCasts to My SD Card)

I have been an iPodder user for a while now. And like others I have been thinking about content management. When you are downloading large MP3 files it makes sense to find ways to try to manage these files. Because iPodder works with iTunes and because there is an API available for iTunes (on Windows) I have created some VBScript files to help me perform some common tasks.

First of all the way that I manage my files in iTunes is to display the “Last Played” column (if it is not visible in your iTunes just right click on the header and click “Last Played”). With the “Last Played” column I can quickly tell if I have listened to the PodCast or not.

The first thing that I wanted to manage was to be able to copy newly downloaded PodCasts to my Pocket PC (I have not broken down and bought and iPod yet). The script that I wrote will scan the files in iTunes looking for files that have been added in the last seven days (“Date Added” is within seven days), has not been listened to (“Last Played” is blank) and is in the iPodder download directory (this should be “My Documents\ My Received Files” directory). The files that are found will be copied to a directory that I pass into the script. I have also added a –U flag that will update the “Last Played” column to now (I assume that if I copy the files to my Pocket PC that I will listen to them on my Pocket PC).

Example:

I have a batch file with the following in it.
iNewPodCasts -U E:\Podcasts

Where iNewPodCasts is the VBScript file and –U is the flag to update the “Last Played” column and E:\Podcasts is the destination folder (my SD card that I will use in my Pocket PC). It should also be noted that the E:\Podcasts directory must exist.

Additionally I have also added a –L flag to the iNewPodCasts VBScript that will just list the new PodCast files. This is useful if you don’t want to copy the PodCast files but just see what the new PodCast are. If you use the –L flag the destination directory will be ignored.

Here is the code.
My apologies for the formatting. (Formatted)

001 '-----------------------------------------------------------------------------------
002 ' This will copy newly downloaded files from iPodder to a specified directory. Files
003 ' from the "My Documents\My Received Podcasts" directory that have not been played
004 ' and have been downloaded within the last seven days will be copied to the
005 ' destination folder. If the –U flag is in the command line argument then the
006 ' “Last Played” column will be set to now). If the –L flag is in the command line
007 ' then the files will only be listed and not copied.
008 '
009 ' By: Richard Todosichuk
010 ' rtodosic@hotmail.com
011 '-----------------------------------------------------------------------------------
012 Option Explicit
013
014 Dim fso ' Scripting.FileSystemObject object used to copy files.
015 Dim Shell ' WScript.Shell object used to access information about the windows shell.
016 Dim args ' The command line argurments.
017 Dim arg ' A command line argurment.
018 Dim iTunesApp ' iTunes.Application object used to access the iTunes application.
019 Dim mainLibrary ' The iTunes Library object.
020 Dim tracks ' The tracks collection object of the Library object.
021 Dim currTrack ' The current track object from the Library in iTunes.
022 Dim TestDate ' Now minus seven days.
023 Dim PodCastDir ' The iPodder root download directory.
024 Dim FileList ' The list of files that have been copied.
025 Dim DestFolder ' The destination folder.
026 Dim UpdateLastPlayed ' Flag to update Last Played column in iTunes.
027 Dim ListOnly ' Flag to display only a list of resent PodCasts.
028 Dim i ' A counter variable.
029 Dim Msg ' A string for a message.
030 Dim f ' A file object.
031
032 Set args = WScript.Arguments
033 Set fso = CreateObject("Scripting.FileSystemObject")
034
035 UpdateLastPlayed = False
036 ListOnly = False
037 DestFolder = ""
038
039 FileList = ""
040 TestDate = (Date - 7)
041
042 ' Scan command line arguments
043 For Each arg in args
044 ' Is it a flag.
045 If Instr(1, arg, "-", 1) = 1 or Instr(1, arg, "/", 1) = 1 Then
046 ' Check for list flag
047 If UCase(arg) = "-L" or UCase(arg) = "/L" then
048 ListOnly = True
049 End If
050
051 ' Check for update flag
052 If UCase(arg) = "-U" or UCase(arg) = "/U" Then
053 UpdateLastPlayed = True
054 End If
055 Else
056 ' Only grab the first none flag
057 If DestFolder = "" Then
058 DestFolder = arg
059 End If
060 End If
061 Next
062
063 If args.Count > 0 and (ListOnly or fso.FolderExists(DestFolder)) Then
064 If (not ListOnly) and (not fso.FolderExists(DestFolder)) Then
065 WScript.Echo "Folder " & chr(34) & DestFolder & chr(34) & " not found!"
066 Else
067 Set fso = CreateObject("Scripting.FileSystemObject")
068 Set Shell = CreateObject("WScript.Shell")
069 Set iTunesApp = CreateObject("iTunes.Application.1")
070 Set mainLibrary = iTunesApp.LibraryPlaylist
071 Set tracks = mainLibrary.Tracks
072
073 PodCastDir = Shell.SpecialFolders("MyDocuments") & "\My Received Podcasts\"
074
075 For i = 1 to tracks.Count
076 Set currTrack = tracks.Item(i)
077 IF currTrack.Kind = 1 And _
078 currTrack.DateAdded > TestDate And _
079 currTrack.PlayedDate = 0 AND _
080 currTrack.Location <> "" Then
081 If Instr(1, currTrack.Location, PodCastDir, 1) > 0 then
082 If (fso.FileExists(currTrack.Location)) Then
083 'Build msg of all files
084 If FileList <> "" Then
085 FileList = FileList & chr(13) & chr(10) & currTrack.Location
086 Else
087 FileList = currTrack.Location
088 End If
089
090 If not ListOnly Then
091 'Move the file
092 Set f = fso.GetFile(currTrack.Location)
093 f.Copy DestFolder & "\" & f.name
094 End If
095
096 If UpdateLastPlayed Then
097 'Set the lasted played to now.
098 currTrack.PlayedDate = Date
099 End If
100 End If
101 End If
102 End If
103 Next
104
105 If FileList = "" Then
106 WScript.Echo "No new files found!"
107 ElseIf ListOnly Then
108 WSCript.Echo "The following files are new PodCasts:" & _
109 chr(13) & chr(10) & chr(13) & chr(10) & FileList
110 Else
111 WSCript.Echo "The following files have been copied to " & chr(34) & DestFolder & chr(34) & ":" & _
112 chr(13) & chr(10) & chr(13) & chr(10) & FileList
113 End If
114 End If
115 Else
116 Msg = "Usage: iNewPodCasts [-L] [-U] [destFolder]"
117 Msg = Msg & chr(13) & chr(10) & chr(13) & chr(10) & _
118 "-L - Flag to only list new PodCasts. destFolder will be ignored if specified." & chr(13) & chr(10) & _
119 "-U - Flag to update the Last Played column in iTunes. destFolder must be specified." & chr(13) & chr(10) & _
120 "destFolder - The folder that new PodCasts will be copied too."
121 WScript.Echo Msg
122 End If

(download iNewPodCasts.vbs)
The code is a little long, but not that complicated. Lines 42 to 61 handle searching the command line arguments that were passed into the script. Line 63 checks to see if the arguments are valid and if not then lines 116 to 121 will display a message telling you how to call this script. If the command line arguments are valid then on line 69 the COM object that accesses iTunes is created and from that object the tracks collection of the LibraryPlayList are accessed. Then all tracks in the tracks collection are scanned and checks are performed at line the 77 to 82. Kind of 1 means that the track is a file. DateAdd must be less than the last seven days. PlayedDate is the same as the “Last Played” column and 0 means that it is blank. Location is the full file name of the track. I then check to see the location of the file is in the iPodder root directory and then I check to see that the file does in fact exist. (The file can be deleted or moved and iTunes may be out of date.) Lines 83 to 88 build a string that will be displayed at the end if the execution of the script. Line 93 does the actual copy. Line 98 updates the “Last Played” column to now. For the most part that is all there is to it.

I should also mention that if you are running McAfee or other virus scanners this script may not work.Virus scanner writers like to re-implement the windows system Scripting.FileSystemObject and WScript.Shell objects. You can re-register the original windows COM objects and this will work fine. However, you should be aware that these files have been re-implemented for a reason. I don’t mean to scare people away from doing this but I mention this for two reasons. First I spent hours trying to figure out why things would not work and I don’t what you to do the same. Furthermore, if you have other virus scanners and spyware installed, you may be in luck. Better (well more script friendly) virus scanners and spyware software will detect that you are trying to run these objects and will prompt you to make sure that you really want to run them. This is a good approach. This will allow you to run VBScript files in a secure way. So, you CAN have your scripts and execute them too.