[Music]選択中の音楽ファイルを書き出す
ソース | |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | (* |
004 | |
005 | |
006 | com.cocolog-nifty.quicktimer.icefloe *) |
007 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
008 | ##自分環境がos12なので2.8にしているだけです |
009 | use AppleScript version "2.8" |
010 | use scripting additions |
011 | |
012 | |
013 | |
014 | ###ダイアログ |
015 | set strName to (name of current application) as text |
016 | if strName is "osascript" then |
017 | tell application "Finder" to activate |
018 | else |
019 | tell current application to activate |
020 | end if |
021 | |
022 | set strWithPrompt to "ファイルの書き出し先を選択してください" |
023 | |
024 | set aliasDefaultLocation to path to desktop folder from user domain |
025 | tell 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 |
029 | end tell |
030 | |
031 | |
032 | tell application "Music" |
033 | try |
034 | #選択されているファイルの実体先をリストで取得 |
035 | set listTrackSelection to selection as list |
036 | on error |
037 | ---選択していないとエラーになる |
038 | log "曲を選択してください" |
039 | end try |
040 | log listTrackSelection |
041 | end tell |
042 | |
043 | repeat 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 |
056 | end repeat |
057 | |
058 | tell application "Finder" |
059 | ###書き出し先を選択した状態にする |
060 | reveal aliasExpFolder |
061 | end 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
#########################
| 固定リンク
「Media Music」カテゴリの記事
- [Music]メタデータの文字化け置換(EU系の文字化けの置換) 少し増えた(2024.03.18)
- [shortcut]再生中の音楽をShazamでしらべてタイトルアーティストを設定する(2023.12.11)
- [Music]メタデータの文字化け置換(1つ毎処理)(2023.12.09)
- [afinfo]ミュージックファイルの詳細メタ情報の取得(2023.11.01)
- [com.apple.metadata]オーディオファイルのコメントにビットレートを入れる(2023.11.01)