How to convert this script to JavaScript?


I use this AppleScript on the Mac, but I also need to run it on Windows. I cannot find any documentation on JavaScript for automation. I don’t have to script anything else on Windows, so any help converting this script would be very much appreciated.

PowerShell would also be good. I’m looking here to some ideas

This is a simple script to reset the rating of songs where the album rating was computed, and then the album rating was applied to the song

tell application "iTunes"
	set results to (every file track whose rating > 0 and rating kind is computed and album rating > 0 and album rating kind is user and media kind is song)

	log the number of items in results
	repeat with trk in results
			set album rating of trk to 0

			-- logging
			set theAlbum to album of trk
			set theArtist to artist of trk
			log theAlbum & " by " & theArtist

		on error the the_errormessage number the the_errornumber
			display dialog "Error: " & the_errornumber & ". " & the_errormessage buttons {"Cancel"} default button 1 with icon 2 giving up after 15
		end try

	end repeat
end tell

this page has example JS code.

Your going to have to convert yourself.

Other sites:

Doug is the master with iTunes and AppleScript here’s his recommendations: