Setting Play Count in Music app

Years ago, I modified Doug’s Scripts’ New Play Count script to automatically set every song in a given playlist to zero plays. However, I’ve since upgraded to Catalina, and it no longer works. Unfortunately, it is no longer possible to view the source code of Doug’s scripts, so I can’t use the latest version to update my script. So what do I need to change?

Here’s my old script (I’ve changed “iTunes” to “Music,” but that did not fix the problem :slight_smile:

tell application "Music"
	set sel to every track of playlist "Play Count Util"
	repeat with t in sel
		set t to contents of t
		if class of t is file track or class of t is URL track then
			set played count of t to (0 as integer)
				set played date of t to missing value
			end try
		end if
	end repeat
	set shuffle enabled to false
	play playlist "Go Through"
end tell

Model: MacBook Pro 2015
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14

The above says “macOS 10.14,” but I’m using 10.15. That wasn’t an option in the popup.

Also, it autofilled "Safari 605.1.15,” but Safari says that it’s “Version 15.0 (15612., 15612).”

Speaking of errors in the interface, when I tried to post this, I got the error:
[format]The following errors need to be corrected before the message can be posted:
At least %s seconds have to pass between posts. Please wait %s seconds and try posting again. 60[/format]

Hi Calion.

Thanks for pointing this out. I’ll pass it on to Mark to see if he can update the pop-up. But don’t worry too much about it. It’s just to help people know what system you’re using when it may be relevant to what you’re posting.

That’s a strange one. :confused: I’ve not seen it before. I’ll pass it on too. Thanks!

Nope. It does the exact same thing my script does: just start playing “Go Through,” without changing the play count of the tracks in “Play Count Util."

Go Safari–>Preferences–>Reader, set Automatically put Reader on to OFF.

Following uses getting class of track using keyword its. It seems, this was problematic piece. Updated script:

tell application "Music"
	repeat with t in (get tracks of playlist "Play Count Util")
		tell t to if unplayed is false then
			set itsClass to its class
			if itsClass is in {file track, URL track} then set unplayed to true
		end if
	end repeat
	set shuffle enabled to false
	play playlist "Go Through"
end tell

Thanks, KniazidisR. Hopefully Calion will report back on whether this fixes the “Please wait” problem for them. I see Mark’s now updated the “Operating system” pop-up on the posting pages right up to macOS 12. Posters have to insert the browser information for themselves if they want it to be included in the post.

Model: 2017 iMac
AppleScript: 2.7
Browser: Safari 14.1.2 (14611.
Operating System: macOS 10.14

It’s a default setting on forums to reduce issues with bots, spam and so forth. It will be a preset time like a minute, though might be longer here.

It already is.

Same result. (I’m running these from Script Editor, but that shouldn’t make a difference as far as I’m aware.)

Sure, and if it had said “60” instead of “%s”, I wouldn’t have reported it.

No, it’s not working. I thought for a moment that it might be because the tracks aren’t downloaded to this computer, but Doug’s script works fine on just these tracks.

Did you see Doug’s memo about possible bug

Yes, and I’ve been subject to it for years, but it doesn’t stop the script from changing the play count. As I said, Doug’s New Play Count script works fine.

The main question remains is : what is your playlist “Play Count Util”. It is some downloaded playlist or something other? And, are you sure it is not downloaded to Music library? Because when I try to read play count of free URL track, it has not Get Info either.

If you don’t clarify the situation and the user with a paid account in the iTunes Store does not appear, you are unlikely to be provided with assistance in obtaining a working solution.

Start by believing that the Doug’s app doesn’t do magic that can’t be repeated. One thing is for sure: it is paid, as well as iTunes Store.


It already is or it already was? And what it IS or WAS, ON or OFF? It is fully unclear for other users, and leads them away from understanding the problem and solving it.

I will make it clear and understandable:

[format]Go Safari–>Preferences–>Reader, set “Automatically use Reader” on to ON[/format]
, and you have problems when trying publish post on

[format]Go Safari–>Preferences–>Reader, set “Automatically use Reader” on to OFF[/format]
, and you publish post on without problems

Yes, good question. It’s a Smart Playlist that shows all of the files in the Go Through playlist that don’t have a play count of zero.

iTunes Screenshot

I’m not sure what the iTunes Store has to do with this issue.

That’s exactly where I started, and why I’m harping on this. if Doug’s script can do it, there’s a way to do it. If our script doesn’t do what Doug’s can, we’re doing something wrong.

Come to think of it, perhaps the place to start is to try to replicate Doug’s script, and go from there. That way, nothing in my personal setup could be the problem.

Neither is true. It’s not paid, though donations are appreciated. And it is not iTunes Store, but freely downloadable from his site. It’s just a compiled, protected AppleScript.

If I had just then done it, I wouldn’t have said “it already is.” That seems pretty unambiguous to me. “It’s already the way you suggest.” But sure, it already was off before any of this started.

I don’t think you understand the problem. The problem is that I tried to post twice within 60 seconds, and it wouldn’t let me. But even that isn’t the problem; that’s just part of the design of the system. The problem is that it said “%s” instead of “60s” in the error message.

Okay, let’s leave the hocus pocus with Safari Reader alone. Let’s assume that I misunderstood you.

Finally, I managed to find out from you that you are working with smart-playlist, which is also uploaded to iCloud.

Now, it remains to find out which version of OS X you are working with. Because then you had “Operating System: macOS 10.14”, then you declare that “he above says” macOS 10.14, “but I’m using 10.15.”, But now under the rest of the posts the information is completely erased.

Also, It seems to me that I need to pull out information from you about the version of with pliers. No, I do not intend to do this anymore, as it is tiresome. You have already been answered by a more experienced user than me.

No, the smart playlist is not uploaded to iCloud; smart playlists which reference other smart playlists are not iCloud-compatible.

I’m running Catalina, 10.15.7.

I don’t recall you or anyone asking this before. My iTunes version is Music

My current question is: Can anyone replicate the New Play Count functionality?

Model: MacBook Pro 2015
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.15

@Calion, hello.

You very well provided a screenshot of the “Play Count Util” playlist. Do you see those clouds with an arrow pointing down next to every song? They mean these songs are in iCloud. Now all that remains is to read the bug note posted by @technomorph. Or download the songs to your computer, reset play counts and upload them back to iCloud. If Apple hasn’t fixed this bug yet.

It’s hard to understand why the official New Play page still reminds you that the app doesn’t work with iCloud songs, and you claim it does. I think you better ask the Apple about how your problem is being solved.

Yes, the songs are in iCloud. But the playlists in question are not.

This bug is irrelevant to this situation. a) I’ve been subject to this bug for years; it doesn’t prevent AppleScript from changing the play count at all; it just means that it doesn’t “take” on a permanent basis. I’ve learned to deal with it, but it doesn’t affect the script in question (and, by the way, is unaffected, in my experience, by whether the song is downloaded to my machine. If it’s in iCloud at all—whether downloaded or not—this can happen). b) Doug’s New Play Count script works just fine on exactly these songs in exactly this playlist. So the problem can’t be some iCloud bug; it must be that we aren’t getting the script right.

The New Play page does not at all say that the app doesn’t work with iCloud songs. It just notifies the user of a potential bug that will cause play counts to spontaneously revert. My problem isn’t that the play counts are spontaneously reverting after they’re reset. My problem is that the play counts aren’t resetting—with any script I’ve been able to create—in the first place. Doug’s Script—and doing it manually—works just fine.