Three Is It

Because two isn't enough and four is just too many

Strange women lying in ponds distributing swords is no basis for a system of government!
Monty Python, Monty Python and the Holy Grail
Home Blogs Genealogy Brad's Bookshelf Subscriptions Contact Sign in
 

About the author

Brad Butts is a .NET developer and architect. He is married with children and enjoys reading, working out, and genealogy is his five minutes of spare time.
E-mail me Send mail
National Debt Clock

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Calculating the size of my Playlist

Over the holidays, I bought a Sansa c250 mp3 player, a) because it was cheap and b) because it contains a microSD card expansion slot, which, in theory, would allow me to expand the disk capacity indefinitely.

Before I learned how to upgrade the firmware on the player, I was relegated to using software like Windows Media Player to move MP3s onto the device—a pox on all devices that force you to use special software to move files onto them (like this dumb digital ornament I bought for my dad—sorry, Dad).  At any rate, I wanted to begin using the device and learn how to use the expansion slot later, so I built up a playlist of tons of my favorite podcasts.  Since the player’s disk was only 2gb, though, I had to be careful not to pack too many files into the playlist.  So my question, how do I know the sum total of all the files I’m trying to sync to the player?

Windows Media Player will tell you the total number of files you have in your playlist, it’ll even tell you the total number of hours and minutes your playlist represents, but as far as I can tell it won’t tell you total size of the files represented by the playlist (even though the Library tab will tell you the size of each individual file).

playlist1

Fooey on that.  PowerShell can tell me the answer.  I wrote this script to calculate the total size of the files:

$playlistName = "C:\Documents and Settings\Administrator\My Documents\My Music\My Playlists\talk.wpl"
$playlist = [xml](cat $playlistName)
$totalSize = 0

$files = $playlist.smil.getElementsByTagName("media")

foreach($file in $files)
{
    if(test-path $file.getAttribute("src"))
    {
        $totalSize += (get-item $file.getAttribute("src")).length/1Mb
    }
}

"The total size of " + [io.path]::GetFileName($playlistName) + " is: " + $totalSize + " Mb"

The script produced the following results:

playlist

So it looks like my playlist will fit nicely on my 2gb player.  Problem solved.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Technology Blog
Posted by Brad on Sunday, January 04, 2009 12:06 PM
Permalink | Comments (1) | Post RSSRSS comment feed

Related posts

Comments

openmusicdoors gb

Wednesday, July 01, 2009 7:09 AM

openmusicdoors

Great way to track and calculate the size of the playlist.

Comments are closed