40番さんに色々助けてもらい(一番難しいところは40番さんのプログラム)、QuickTimeのファイルをつなげるAppleScriptが完成した。QuickTimeのファイルをつなげる所は、Westacularさんのスクリプトををベースにモディファイした。これまでのブログの通り、音にこだわると、この方法が現段階のベストと思われる。
●プログラムの動き
1)QuickTimeファイルの入っているフォルダを選択し、このAppleScriptを立ち上げると、すべての曲がつながったファイルが作られる。
2)英語のタイトルは、そのままチャプター表示。
3)日本語のタイトルは、文字化けするので非表示。
曲順にならない場合もあったような気がするが、今のところほとんどうまく動いているので、気にしないでおこうと思う。
この問題は、40番さんに修正して頂いた(修正済みのバージョンをアップしています)。
別バージョンとして、
4)日本語のタイトルの割合が90%以上だったら、英語の曲も含め、すべてTrack番号表示。
も行うプログラムを作ったので、アップしておく(ver. b)。
以下はそのプログラム。
------------------------------------------
-- QuickTime Concatenater ver. a.1.1
tell application "Finder"
set Select_Items to sort selection by name --選択アイテム取得、名前順にソート
repeat with theItem in Select_Items --選択アイテムをひとつずつ
if (class of theItem) is folder and number of (items of theItem) > 0 then
-- 属性が folder で、なおかつ中身が空ではない
repeat with i from 1 to number of (items of theItem) --フォルダの中をひとつずつ
set obj to item i of theItem
if (class of obj) is document file then
-- 属性が document file なら
set FName to name of obj as Unicode text
set ChangedName to my CheckName(FName, i)
-- 連続再生Quicktimeファイルを作る
tell application "QuickTime Player"
if i is equal to 1 then
make new document
end if
open obj
tell document 1
rewind
select all
copy
select none
end tell
close document 1 saving no
tell document 1
add
select none
if i is equal to 1 then
set this_track to make new track at beginning with data "Chapter 1"
set enabled of this_track to false
set the name of this_track to "Chapter Track"
set chapterlist of track 1 to track "Chapter Track"
set the movie_length to the duration
tell chapter 1
set the time to 0
set the duration to movie_length
set the name to ChangedName
end tell
else
set the newmovielength to the duration
set the duration of this_track to newmovielength
set the chapter_list to the name of every chapter
set the new_chapter_list to chapter_list & (i as string)
set the contents of the current chapter track to the new_chapter_list
set the time of chapter i to movie_length
set the duration of chapter i to newmovielength - movie_length
set the name of chapter i of this_track to ChangedName
set movie_length to the duration
end if
end tell
end tell
end if
end repeat
end if
end repeat
tell application "QuickTime Player"
tell document 1
rewind
end tell
end tell
end tell
-- piconv で ASCII に変換、日本語チェック、曲名作成
on CheckName(Mojiretu, Kyokuban)
tell application "Finder"
set ASCII_Name to ""
set myScript to "echo " & (quoted form of Mojiretu) & " | piconv -f utf8 -t ascii"
set ASCII_Name to do shell script myScript
-- 結果で振り分け
if (ASCII_Name as string) is (Mojiretu as string) then
-- 文字化けなく変換された
set Use_Name to Mojiretu
else
if Kyokuban <10 then
set Emoji to my Emoji()
set Use_Name to "0" & (Kyokuban as string) & " " & (Emoji as string) & " "
else
-- 10曲目以上は曲番の前に0を付けない
set Emoji to my Emoji()
set Use_Name to (Kyokuban as string) & " " & (Emoji as string) & " "
end if
end if
return Use_Name
end tell
end CheckName
on Emoji()
set EmojiList to {"(^^;)", "(^^)", "(--)", "(--)", "(++)"}
set RndNum to random number from 1 to 5
return item RndNum of EmojiList
end Emoji
------------------------------------------
下のプログラムは4)を付け加えたバージョン
------------------------------------------
-- QuickTime Concatenater ver. b.1.1
tell application "Finder"
set Select_Items to sort selection by name --選択アイテム取得、名前順にソート
set DenyFlag to my CheckRatio(Select_Items)
repeat with theItem in Select_Items --選択アイテムをひとつずつ
if (class of theItem) is folder and number of (items of theItem) > 0 then
-- 属性が folder で、なおかつ中身が空ではない
repeat with i from 1 to number of (items of theItem) --フォルダの中をひとつずつ
set obj to item i of theItem
if (class of obj) is document file then
-- 属性が document file なら
set FName to name of obj as Unicode text
set ChangedName to my CheckName(FName, i, DenyFlag)
-- 連続再生Quicktimeファイルを作る
tell application "QuickTime Player"
if i is equal to 1 then
make new document
end if
open obj
tell document 1
rewind
select all
copy
select none
end tell
close document 1 saving no
tell document 1
add
select none
if i is equal to 1 then
set this_track to make new track at beginning with data "Chapter 1"
set enabled of this_track to false
set the name of this_track to "Chapter Track"
set chapterlist of track 1 to track "Chapter Track"
set the movie_length to the duration
tell chapter 1
set the time to 0
set the duration to movie_length
set the name to ChangedName
end tell
else
set the newmovielength to the duration
set the duration of this_track to newmovielength
set the chapter_list to the name of every chapter
set the new_chapter_list to chapter_list & (i as string)
set the contents of the current chapter track to the new_chapter_list
set the time of chapter i to movie_length
set the duration of chapter i to newmovielength - movie_length
set the name of chapter i of this_track to ChangedName
set movie_length to the duration
end if
end tell
end tell
end if
end repeat
end if
end repeat
tell application "QuickTime Player"
tell document 1
rewind
end tell
end tell
end tell
on CheckRatio(Select_Items)
tell application "Finder"
set MojibakeNumber to 0
set TotalNumber to 0
repeat with theItem in Select_Items --選択アイテムをひとつずつ
if (class of theItem) is folder then
-- 属性が folderなら
repeat with i from 1 to number of (items of theItem) --フォルダの中をひとつずつ
set obj to item i of theItem
if (class of obj) is document file then
set FName to name of obj as Unicode text
-- piconv で ASCII に変換。
set ASCII_Name to ""
set myScript to "echo " & (quoted form of FName) & " | piconv -f utf8 -t ascii"
set ASCII_Name to do shell script myScript
-- 結果で振り分け
if not (ASCII_Name as string) is (FName as string) then
set MojibakeNumber to MojibakeNumber + 1
set TotalNumber to TotalNumber + 1
else
set TotalNumber to TotalNumber + 1
end if
end if
end repeat
end if
end repeat
set JapaneseRatio to MojibakeNumber / TotalNumber
if (JapaneseRatio > 0.9) then
set DenyTitile to true
else
set DenyTitile to false
end if
return DenyTitile
end tell
end CheckRatio
-- piconv で ASCII に変換、日本語チェック、曲名作成
on CheckName(Mojiretu, Kyokuban, DenyFlagSub)
tell application "Finder"
set ASCII_Name to ""
set myScript to "echo " & (quoted form of Mojiretu) & " | piconv -f utf8 -t ascii"
set ASCII_Name to do shell script myScript
-- 結果で振り分け
if (ASCII_Name as string) is (Mojiretu as string) then
-- 文字化けなく変換された
if DenyFlagSub is true then
set Use_Name to "Track " & (Kyokuban as string)
else
set Use_Name to Mojiretu
end if
else
if DenyFlagSub is true then
set Use_Name to "Track " & (Kyokuban as string)
else
if Kyokuban <10 then
set Emoji to my Emoji()
set Use_Name to "0" & (Kyokuban as string) & " " & (Emoji as string) & " "
else
-- 10曲目以上は曲番の前に0を付けない
set Emoji to my Emoji()
set Use_Name to (Kyokuban as string) & " " & (Emoji as string) & " "
end if
end if
end if
return Use_Name
end tell
end CheckName
on Emoji()
set EmojiList to {"(^^;)", "(^^)", "(--)", "(--)", "(++)"}
set RndNum to random number from 1 to 5
return item RndNum of EmojiList
end Emoji
------------------------------------------
●プログラムの動き
1)QuickTimeファイルの入っているフォルダを選択し、このAppleScriptを立ち上げると、すべての曲がつながったファイルが作られる。
2)英語のタイトルは、そのままチャプター表示。
3)日本語のタイトルは、文字化けするので非表示。
この問題は、40番さんに修正して頂いた(修正済みのバージョンをアップしています)。
別バージョンとして、
4)日本語のタイトルの割合が90%以上だったら、英語の曲も含め、すべてTrack番号表示。
も行うプログラムを作ったので、アップしておく(ver. b)。
以下はそのプログラム。
------------------------------------------
-- QuickTime Concatenater ver. a.1.1
tell application "Finder"
set Select_Items to sort selection by name --選択アイテム取得、名前順にソート
repeat with theItem in Select_Items --選択アイテムをひとつずつ
if (class of theItem) is folder and number of (items of theItem) > 0 then
-- 属性が folder で、なおかつ中身が空ではない
repeat with i from 1 to number of (items of theItem) --フォルダの中をひとつずつ
set obj to item i of theItem
if (class of obj) is document file then
-- 属性が document file なら
set FName to name of obj as Unicode text
set ChangedName to my CheckName(FName, i)
-- 連続再生Quicktimeファイルを作る
tell application "QuickTime Player"
if i is equal to 1 then
make new document
end if
open obj
tell document 1
rewind
select all
copy
select none
end tell
close document 1 saving no
tell document 1
add
select none
if i is equal to 1 then
set this_track to make new track at beginning with data "Chapter 1"
set enabled of this_track to false
set the name of this_track to "Chapter Track"
set chapterlist of track 1 to track "Chapter Track"
set the movie_length to the duration
tell chapter 1
set the time to 0
set the duration to movie_length
set the name to ChangedName
end tell
else
set the newmovielength to the duration
set the duration of this_track to newmovielength
set the chapter_list to the name of every chapter
set the new_chapter_list to chapter_list & (i as string)
set the contents of the current chapter track to the new_chapter_list
set the time of chapter i to movie_length
set the duration of chapter i to newmovielength - movie_length
set the name of chapter i of this_track to ChangedName
set movie_length to the duration
end if
end tell
end tell
end if
end repeat
end if
end repeat
tell application "QuickTime Player"
tell document 1
rewind
end tell
end tell
end tell
-- piconv で ASCII に変換、日本語チェック、曲名作成
on CheckName(Mojiretu, Kyokuban)
tell application "Finder"
set ASCII_Name to ""
set myScript to "echo " & (quoted form of Mojiretu) & " | piconv -f utf8 -t ascii"
set ASCII_Name to do shell script myScript
-- 結果で振り分け
if (ASCII_Name as string) is (Mojiretu as string) then
-- 文字化けなく変換された
set Use_Name to Mojiretu
else
if Kyokuban <10 then
set Emoji to my Emoji()
set Use_Name to "0" & (Kyokuban as string) & " " & (Emoji as string) & " "
else
-- 10曲目以上は曲番の前に0を付けない
set Emoji to my Emoji()
set Use_Name to (Kyokuban as string) & " " & (Emoji as string) & " "
end if
end if
return Use_Name
end tell
end CheckName
on Emoji()
set EmojiList to {"(^^;)", "(^^)", "(--)", "(--)", "(++)"}
set RndNum to random number from 1 to 5
return item RndNum of EmojiList
end Emoji
------------------------------------------
下のプログラムは4)を付け加えたバージョン
------------------------------------------
-- QuickTime Concatenater ver. b.1.1
tell application "Finder"
set Select_Items to sort selection by name --選択アイテム取得、名前順にソート
set DenyFlag to my CheckRatio(Select_Items)
repeat with theItem in Select_Items --選択アイテムをひとつずつ
if (class of theItem) is folder and number of (items of theItem) > 0 then
-- 属性が folder で、なおかつ中身が空ではない
repeat with i from 1 to number of (items of theItem) --フォルダの中をひとつずつ
set obj to item i of theItem
if (class of obj) is document file then
-- 属性が document file なら
set FName to name of obj as Unicode text
set ChangedName to my CheckName(FName, i, DenyFlag)
-- 連続再生Quicktimeファイルを作る
tell application "QuickTime Player"
if i is equal to 1 then
make new document
end if
open obj
tell document 1
rewind
select all
copy
select none
end tell
close document 1 saving no
tell document 1
add
select none
if i is equal to 1 then
set this_track to make new track at beginning with data "Chapter 1"
set enabled of this_track to false
set the name of this_track to "Chapter Track"
set chapterlist of track 1 to track "Chapter Track"
set the movie_length to the duration
tell chapter 1
set the time to 0
set the duration to movie_length
set the name to ChangedName
end tell
else
set the newmovielength to the duration
set the duration of this_track to newmovielength
set the chapter_list to the name of every chapter
set the new_chapter_list to chapter_list & (i as string)
set the contents of the current chapter track to the new_chapter_list
set the time of chapter i to movie_length
set the duration of chapter i to newmovielength - movie_length
set the name of chapter i of this_track to ChangedName
set movie_length to the duration
end if
end tell
end tell
end if
end repeat
end if
end repeat
tell application "QuickTime Player"
tell document 1
rewind
end tell
end tell
end tell
on CheckRatio(Select_Items)
tell application "Finder"
set MojibakeNumber to 0
set TotalNumber to 0
repeat with theItem in Select_Items --選択アイテムをひとつずつ
if (class of theItem) is folder then
-- 属性が folderなら
repeat with i from 1 to number of (items of theItem) --フォルダの中をひとつずつ
set obj to item i of theItem
if (class of obj) is document file then
set FName to name of obj as Unicode text
-- piconv で ASCII に変換。
set ASCII_Name to ""
set myScript to "echo " & (quoted form of FName) & " | piconv -f utf8 -t ascii"
set ASCII_Name to do shell script myScript
-- 結果で振り分け
if not (ASCII_Name as string) is (FName as string) then
set MojibakeNumber to MojibakeNumber + 1
set TotalNumber to TotalNumber + 1
else
set TotalNumber to TotalNumber + 1
end if
end if
end repeat
end if
end repeat
set JapaneseRatio to MojibakeNumber / TotalNumber
if (JapaneseRatio > 0.9) then
set DenyTitile to true
else
set DenyTitile to false
end if
return DenyTitile
end tell
end CheckRatio
-- piconv で ASCII に変換、日本語チェック、曲名作成
on CheckName(Mojiretu, Kyokuban, DenyFlagSub)
tell application "Finder"
set ASCII_Name to ""
set myScript to "echo " & (quoted form of Mojiretu) & " | piconv -f utf8 -t ascii"
set ASCII_Name to do shell script myScript
-- 結果で振り分け
if (ASCII_Name as string) is (Mojiretu as string) then
-- 文字化けなく変換された
if DenyFlagSub is true then
set Use_Name to "Track " & (Kyokuban as string)
else
set Use_Name to Mojiretu
end if
else
if DenyFlagSub is true then
set Use_Name to "Track " & (Kyokuban as string)
else
if Kyokuban <10 then
set Emoji to my Emoji()
set Use_Name to "0" & (Kyokuban as string) & " " & (Emoji as string) & " "
else
-- 10曲目以上は曲番の前に0を付けない
set Emoji to my Emoji()
set Use_Name to (Kyokuban as string) & " " & (Emoji as string) & " "
end if
end if
end if
return Use_Name
end tell
end CheckName
on Emoji()
set EmojiList to {"(^^;)", "(^^)", "(--)", "(--)", "(++)"}
set RndNum to random number from 1 to 5
return item RndNum of EmojiList
end Emoji
------------------------------------------
日本語が含まれる曲名をランダムに絵文字にするのは面白いアイデアですね。
> 曲順にならない場合もあったような気がするが
set Select_Items to sort selection by name --選択アイテム取得
↑ソートすれば大丈夫だと思いますよ。
って、私が最初からそう書けばよかったんですね…
絵文字にする前は、『 01 Japanease title 』としていたのですが、これがたくさん表示されると、何とも、殺風景だなぁ、と感じていました。