Powershell and MP3’s

I’ve been trying in vain to organize my substantial MP3 collection.  I know that in the age of streaming MP3’s are passe, but I just can’t quit ’em.  I listen to a lot of music that isn’t readily available for streaming.

One of the things I’m nitpicky about is Genre tagging.  I like that stuff to be correct.  Thing is, sometimes I get lazy.  So, I dug in to see if I could hack out a quick script to scan subdirectories in my collection and root out MP3’s with incorrect or missing Genre tags. This is a very raw little script with zero error handling.  It examines the first file in every subdir, and writes to an output file every directory where that first file’s genre tag doesn’t match what it should.  It requires taglib-sharp.dll.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# uses taglib-sharp.dll
[Reflection.Assembly]::LoadFrom("E:\taglib-sharp.dll")

$outfile = "outfile.csv"
$basedir = "I:\SORTED\Classic Rock"
$subdirs = Get-ChildItem $basedir -attributes D

foreach ($subdir in $subdirs) {
$file = Get-ChildItem $subdir.fullname -Filter *.mp3 | Select-Object -First 1
$ff=$file.fullname
$f = [TagLib.File]::Create("$ff")
$genre = $f.Tag.Genres
$outt = "$subdir `t $genre"
$outt
if ($outt -NotMatch 'Classic Rock') {
$outt | out-file $outfile -append
}
$f = ""
}

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">