« [CICode128BarcodeGenerator]Code128バーコード作成 | トップページ | [Music]アルバムアーティストの変更 »

[Music]Musicアプリの設定を初期化する

注意
音楽ファイルの入ったフォルダはデスクトップに移動されます。
実行後に電源OFF-ONでリセット完了です


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()


set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSMusicDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidMusicDirPathURL to ocidURLsArray's firstObject()
set ocidMusicContentsDirPathURL to ocidMusicDirPathURL's URLByAppendingPathComponent:("Music")


set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()

set ocidBackupDirPathURL to ocidDesktopDirPathURL's URLByAppendingPathComponent:("Music.backup")

set listDone to appFileManager's moveItemAtURL:(ocidMusicContentsDirPathURL) toURL:(ocidBackupDirPathURL) |error|:(reference)
log item 1 of listDone


####################################
### ライブラリ内処理
set listPath to {"~/Library/Caches/com.apple.Music", "~/Library/Caches/com.apple.itunescloudd", "~/Library/Caches/com.apple.iTunesCloud", "~/Library/Caches/com.apple.iTunes", "~/Library/Application Support/com.apple.MediaPlayer", "~/Library/Containers/com.apple.Music.MusicStorageExtension", "~/Library/Containers/com.apple.Music.MusicCacheExtension", "~/Library/Containers/com.apple.Music.MPMusicPlayerApplicationControllerInternal", "~/Library/HTTPStorages/com.apple.Music", "~/Library/WebKit/com.apple.Music", "~/Library/Application Support/CloudDocs/session/containers/iCloud.com.apple.itunesu.plist", "~/Library/Preferences/com.apple.itunesstored.plist", "~/Library/Preferences/com.apple.itunescloud.plist", "~/Library/Preferences/com.apple.itunescloud.daemon.plist", "~/Library/Preferences/com.apple.iTunes.plist", "~/Library/Preferences/com.apple.iTunes.Gracenote.plist", "~/Library/Preferences/com.apple.itunes.altool.plist", "~/Library/Preferences/com.apple.Music.plist", "~/Library/Preferences/com.apple.Music.eq.plist", "~/Music/Music/Music Library.musiclibrary", "~/Library/IntelligencePlatform/Artifacts/appleMusicEvent", "~/Library/com.apple.AppleMediaServices/PersistedBags/com.apple.Music", "~/Library/HTTPStorages/com.apple.Music", "~/Library/Application Support/com.apple.MediaPlayer", "~/Library/Application Scripts/com.apple.Music.MusicCacheExtension", "~/Library/Application Scripts/com.apple.Music.MusicStorageExtension"} as list



repeat with itemPath in listPath
  set strPath to itemPath as text
  set ocidFilePathStr to (refMe's NSString's stringWithString:(strPath))
  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
  set listDone to (appFileManager's trashItemAtURL:(ocidFilePathURL) resultingItemURL:(ocidFilePathURL) |error|:(reference))
  log item 1 of listDone
end repeat

####################################
### ByHost内処理
set listPath to {"$HOME/Library/Preferences/ByHost/com.apple.music", "$HOME/Library/Preferences/ByHost/com.apple.Music", "$HOME/Library/Preferences/ByHost/com.apple.itunes", "$HOME/Library/Preferences/ByHost/com.apple.iTunes"} as list

set strCommandText to ("/bin/mkdir -p $HOME/.Trash/ByHost") as text
do shell script strCommandText

repeat with itemPath in listPath
  set strPath to itemPath as text
  set strCommandText to ("/usr/bin/touch \"" & strPath & "\"") as text
  do shell script strCommandText
  
  set strCommandText to ("/bin/mv -f " & strPath & "* $HOME/.Trash/ByHost") as text
  do shell script strCommandText
end repeat

####################################
### T
set listPath to {"com.apple.music", "com.apple.Music", "com.apple.itunes", "com.apple.iTunes"} as list
set ocidTempDirURL to appFileManager's temporaryDirectory()

repeat with itemPath in listPath
  set ocidGoToTrashPathURL to (ocidTempDirURL's URLByAppendingPathComponent:(strPath))
  set listDone to (appFileManager's trashItemAtURL:(ocidGoToTrashPathURL) resultingItemURL:(ocidGoToTrashPathURL) |error|:(reference))
  log item 1 of listDone
end repeat

####################################
### C

set listPath to {"com.apple.music", "com.apple.Music", "com.apple.itunes", "com.apple.iTunes"} as list
set ocidFolderDirPathURL to ocidTempDirURL's URLByDeletingLastPathComponent()
repeat with itemPath in listPath
  set strPath to ("C/" & itemPath) as text
  set ocidGoToTrashPathURL to (ocidFolderDirPathURL's URLByAppendingPathComponent:(strPath))
  set listDone to (appFileManager's trashItemAtURL:(ocidGoToTrashPathURL) resultingItemURL:(ocidGoToTrashPathURL) |error|:(reference))
  log item 1 of listDone
end repeat



|

« [CICode128BarcodeGenerator]Code128バーコード作成 | トップページ | [Music]アルバムアーティストの変更 »

AppleScript Music」カテゴリの記事