« [Music]アルバムアーティストの変更 | トップページ | [Music]アルバムアーティストを削除してコンピレーションにする »

[Music]選択中の音楽ファイルを書き出す


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

[Music]選択中の音楽ファイルを書き出す .scpt
ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(*
004
005
006com.cocolog-nifty.quicktimer.icefloe *)
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008##自分環境がos12なので2.8にしているだけです
009use AppleScript version "2.8"
010use scripting additions
011
012
013
014###ダイアログ
015set strName to (name of current application) as text
016if strName is "osascript" then
017   tell application "Finder" to activate
018else
019   tell current application to activate
020end if
021
022set strWithPrompt to "ファイルの書き出し先を選択してください"
023
024set aliasDefaultLocation to path to desktop folder from user domain
025tell application "SystemUIServer"
026   activate
027   #ダイアログを出して選択されたフォルダをコピー先とする
028   set aliasExpFolder to (choose folder default location aliasDefaultLocation with prompt strWithPrompt without invisibles, multiple selections allowed and showing package contents) as alias
029end tell
030
031
032tell application "Music"
033   try
034      #選択されているファイルの実体先をリストで取得
035      set listTrackSelection to selection as list
036   on error
037      ---選択していないとエラーになる
038      log "曲を選択してください"
039   end try
040   log listTrackSelection
041end tell
042
043repeat with objTrack in listTrackSelection
044   tell application "Music"
045      set aliasLocation to location of objTrack as alias
046      log aliasLocation
047   end tell
048   tell application "Finder"
049      try
050         duplicate aliasLocation to aliasExpFolder
051      on error
052         ###すでに同名がある場合はエラーになる
053         log "同名のファイルがすでにありました"
054      end try
055   end tell
056end repeat
057
058tell application "Finder"
059   ###書き出し先を選択した状態にする
060   reveal aliasExpFolder
061end tell
AppleScriptで生成しました

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions

######ログ表示
doLogView()

property refMe : a reference to current application

set strWithPrompt to "ファイルの書き出し先を選択してください"

set aliasDefaultLocation to path to desktop folder from user domain
tell application "Finder"
activate
---ダイアログを出して選択されたフォルダをコピー先とする
set aliasExpFolder to (choose folder default location aliasDefaultLocation ¬
with prompt strWithPrompt ¬
invisibles false ¬
without multiple selections allowed and showing package contents) as alias
end tell


tell application "Music"
try
----選択されているファイルの実体先をリストで取得
set listTrackSelection to selection as list
on error
---選択していないとエラーになる
log "曲を選択してください"
end try
log listTrackSelection
end tell

repeat with objTrack in listTrackSelection
tell application "Music"
set aliasLocation to location of objTrack as alias
log aliasLocation
end tell
tell application "Finder"
try
duplicate aliasLocation to aliasExpFolder
on error
###すでに同名がある場合はエラーになる
log "同名のファイルがすでにありました"
end try
end tell
end repeat

tell application "Finder"
###書き出し先を選択した状態にする
reveal aliasExpFolder
end tell




display notification "処理終了" with title "処理が終了" subtitle "処理が終了しました" sound name "Sonumi"
log ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"
return ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"




#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
tell application "Script Editor"
tell application "System Events"
tell process "Script Editor"
tell window 1
tell splitter group 1
tell splitter group 1
tell group 1
tell checkbox "返された値"
set boolValue to value as boolean
end tell
if boolValue is false then
click checkbox "返された値"
end if
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
end repeat

end doLogView
#########################

|

« [Music]アルバムアーティストの変更 | トップページ | [Music]アルバムアーティストを削除してコンピレーションにする »

Media Music」カテゴリの記事