I used to use vbscripts to automate tasks such as adding mp3, changing genre, comments for tracks in iTunes.
I am now trying to create powershell scripts to do the same. I can added mp3 to iTunes, but I failed to change the properties of the track…. I don’t know what I’ve missed…. The following is a sample of the powershell codes to change the Genre and the error said the property “genre” does not exist.
$iTunes = New-Object -com "iTunes.Application"
$library = $iTunes.LibraryPlaylist
$iTrack = $library.addfile("c:\temp\test.mp3")
$iTrack.tracks.Genre = "test"
However, I can see the property using $iTrack.tracks | get-member
Genre Property string Genre () {get} {set}
Thanks to anyone who could help..
I found two ways (there’s more) to set properties.
Force the track to an array and set the properties of the first item
@($iTrack.Tracks)[0].Genre = “test”
Set properties by item name (which is kind of occurred when the object you have is already the one you want to set)
$iTrack.Tracks.ItemByName(‘song name’).Genre = “test”