dougscripts.com

Miscellaneous

January 13 2022 - 6:39 pm

UPDATED: Flush Apple Music Cache Files v2.1

Apple Music stores the audio files it plays in ~/Library/Caches/com.apple.Music/SubscriptionPlayCache/. This script will simply delete that folder.

The files in this folder are specially protected audio files that are downloaded and cached when you play a track from Apple Music on your Mac. They can't be user-played and are only useful to Apple Music, ostensibly so they needn't be re-downloaded if they are played again. (This cache folder doesn't pertain to Radio music. Or to Apple Music you've added to your library for offline listening, the files of which are stored in your "Media" folder.)

Latest version:

  • Minor UI and performance improvements

More information for Flush Apple Music Cache Files v2.1 and download link is here.

December 18 2021 - 4:11 pm

UPDATED: Doug's Check for Update v2.1

Apps and some AppleScript applets from this website already have a "Check for Update..." menu command. But for those that don't, this applet can check for the latest version. Simply drag-and-drop an AppleScript to this applet's icon or double-click to it launch and choose an AppleScript on your machine via an Open Panel to initiate the check.

Latest version:

  • Officially compiled as Universal
  • Commensurate improvements for M1 Macs

More information for Doug's Check for Update v2.1 and download link is here.

August 27 2021 - 11:15 pm

UPDATED: Doug's Check For All Updates v1.5

For macOS 10.14 and later. This script will survey your computer for AppleScripts downloaded from dougscripts.com and create a report, locally stored and viewable in your web browser, listing the scripts for which updates are available and links to download them.

Latest version:

  • General maintenance update
  • Accommodations for macOS 11 and later

More information for Doug's Check For All Updates v1.5 and download link is here.

August 19 2020 - 3:08 pm

Have a Quick Look

I was going to write this up for downloading but it's almost too simple.

Select a track in the Music app and run this script to open a Quick Look panel displaying the track's file, ready to play.

tell application "Music"

try

set sel to selection

if sel is {} then return

set theTrack to item 1 of sel

tell me to doQuickLook(POSIX path of ((get theTrack's location) as text))

on error

return

end try

end tell

on doQuickLook(loc)

try

do shell script "qlmanage -p " & quoted form of loc & " >& /dev/null &"

end try

end doQuickLook

March 15 2020 - 5:38 pm

UPDATED: Doug's Check For All Updates v1.3

For macOS 10.10 and later. This script will survey your computer for AppleScripts downloaded from dougscripts.com and create a report, locally stored and viewable in your web browser, listing the scripts for which updates are available and links to download them

Latest version:

  • Maintenance update

More information for Doug's Check For All Updates v1.3 and download link is here.

May 3 2019 - 1:54 pm

Do Some (Very) Rough Audio Editing in iTunes

This is not a tip for everyone.

You may be aware that Apple added some editing capabilities to Quick Look. For instance, Markup is available to edit text and image documents and Trim is available to edit video and audio files.

Using the script Have a Quick Look, a track can be selected in iTunes and its file displayed in a Quick Look window, via the qlmanage command:

The scrub/trim area becomes available after clicking the Trim button which initially appears in the upper-right corner of the window.

If this suggests to the suggestible reader that this makes a handy audio editor, think twice: editing this way is not very precise and accepted changes are permanent. But, for trimming large audio files of "dead air" or crowd noise or what have you, some may find it convenient.

February 9 2017 - 7:45 am

NEW: Launch at Login v1.0

It is often convenient and desirable to have your designated iTunes Media folder—the folder pointed to in the "Advanced" tab of iTunes' Preferences—located on a large external drive or server. Those of you who do this know the advantages.

But.

An issue that has been known to occur with this configuration is that if the volume or server containing the designated iTunes Media folder does not mount during the computer's startup before iTunes launches, iTunes will presume that this folder is inaccessible and it will default to using the ~/Music/iTunes/iTunes Media/ folder instead. It does this because it needs a definitive place in which to save CD rips (which still happen at my house), converted files and Store purchases.

(More modern versions of iTunes are much better at reverting to the designated iTunes Media folder if its volume is mounted later. But for years this was always dicey and still can be.)

This swapping of designated iTunes Media folders can be problematic. It can render tracks in the iTunes library dead, duplicated, missing, orphaned. And so on.

My podcast partner, Kirk McElhearn, and I discuss this issue on an upcoming episode of The Next Track podcast concerning using a network-attached storage device (NAS) to store iTunes media. In conjunction with that episode, I wrote a script applet to be used as a "Login Item", Launch at Login, that will attempt to mount the volume at startup, confirm it is actually mounted and only then launch iTunes.

Typically, AppleScript can use the mount volume command, which under some circumstances requires providing a username and password. I didn't want to do that because 1) it is difficult for AppleScript to securely manage storing that data and 2) it is awkward having users edit the script to "hard-code" their username and password. But this script avoids having to do that—and not in any devious way—by attempting to open a folder on the volume pointed to by an alias to it in a specific local folder on the startup drive. In order to open this alias'd folder the operating system will be obliged to mount the volume/server it is on; the script will wait until that folder is accessible and then will launch iTunes. If, for some reason, the folder does not become accessible within a reasonable amount of time because the volume didn't mount, the script will not launch iTunes and will display an alert saying so. At that point the user can decide what to do; presumably, mount the server and then launch iTunes manually.

The anxious part of me feels obliged to note that this script does not use any security (other than being signed with my Developer ID) so if you do not want a volume or server to be mounted in unattended startup situations then do not use it.

There are some simple yet specific instructions and caveats to heed before using the script at your house so be sure to read the documentation that accompanies the script in the download. More information about the Launch at Login applet and download is on this page.

November 11 2016 - 8:16 am

UPDATED: Doug's Check For Update v1.2

Doug's Check For Update v1.2 is now available. This applet/droplet will check if an AppleScript that has been downloaded from this site to your computer has a newer version available.

This latest version fixes a problem that was occurring on some systems whereby the droplet function was not recognizing dropped files. It could still be used as an applet by double-clicking, but the handy drag-and-drop feature was amiss; this is fixed.

The script, for macOS 10.8 and later only, is free and can be downloaded from this page.

November 24 2015 - 10:22 am

NEW: Doug's Check For Update

While some applets and all apps from this site have a menu command to "Check for Update...", many AppleScripts do not. To make it easier to check if a script you downloaded at one time or another has a newer version available, use Doug's Check For Update. Just drop an AppleScript file on it (or launch it and use an Open Panel to navigate to a specific script) and it will check the website for the latest version of that script:

Doug's Check For Update

Sure, it'd be great if I could include a Sparkle-like mechanism to automatically check and install updates—as my apps do. But the code required to do so would just add too much overhead to a—very likely—simple AppleScript.

More information and download is here.

September 26 2015 - 8:47 am

NEW: Flush Apple Music Cache Files

The first wave of Apple Music trials will be expiring soon and if you haven't subscribed for real it means saying so long to any Apple Music added to your iTunes library.

But as Kirk pointed out a while back, there may be some residual files left over in the ~/Library/Caches/com.apple.iTunes/SubscriptionPlayCache/ folder, which is sort of like an "iTunes Media" folder for Apple Music. It stores the specially protected audio files that are downloaded when you play a track from Apple Music on your Mac, ostensibly so iTunes doesn't have to re-download them if they are played again. They can't be user-played and are only useful to Apple Music. (This cache folder doesn't apply to Radio music. Or to Apple Music you've added to your library for offline use, which is stored in your official "ITunes Media" folder.)

I'm not sure if these files will disappear when the trial ends for you. iTunes doesn't appear to remove them even now, so if you've used Apple Music a lot then this folder will be loaded with quite a number of full-sized audio files. I'm a sucker for some of those "For You" playlists and I've managed to get my own cache folder up to about 7GB.

Flush Apple Music Cache Files is a simple script that will show the number of files in the cache and the space they take up and, if you wish, delete them:

And if you're subscribing to Apple Music and are tight on drive space, you can flush all you want anytime. Apple Music will re-download any music it requires again later.

Download the script from this page.

Site contents © 2001 - 2022 (that's right: 2001) Doug Adams and weblished by Doug Adams. Contact support AT dougscripts DOT com. About.
All rights reserved. Privacy.
AppleScript, iTunes, iPod, iPad, and iPhone are registered trademarks of Apple Inc. This site has no direct affiliation with Apple, Inc.
The one who says "it cannot be done" should not be interrupting the one who is doing it.