おもろい、めずらしいアップルスクリプト発表会 5

このエントリーをはてなブックマークに追加
31名称未設定
なんかさびしいんで外出ネタをひとつ
以前、別スレで発表したWindows Media 連続再生メタファイルを作るスクリプト。
パンサで使えますかねえ?

on open file_list
tell application "Finder"
set file_list to (sort file_list by name) as list
set current_folder to container of item 1 of file_list
set wvx_text to ""
repeat with wm_file in file_list
set wvx_text to wvx_text & "<entry><ref href=\"./" & name of wm_file & "\"/></entry>" & return
end repeat
set wvx_text to "<asx version=\"3.0\">" & return & wvx_text & "</asx>"
set wvx_file to (make file with properties {creator type:"Ms01"} at current_folder) as alias
try
open for access wvx_file with write permission
write wvx_text to wvx_file
close access wvx_file
on error
close access wvx_file
end try
end tell
end open
32名称未設定:03/11/29 01:34 ID:pDrLkXiZ
ついでに「abc1.wmv」みたいなファイル名を「abc01.wmv」みたいに書き換えるスクリプト。

on open file_list
tell application "Finder"
set suf_fix to text returned of (display dialog "拡張子" default answer "")
set old_delim to AppleScript's text item delimiters
repeat with cur_file in file_list
set file_name to name of cur_file
set AppleScript's text item delimiters to suf_fix
set file_name to text item 1 of file_name
set AppleScript's text item delimiters to old_delim
if (character -1 of file_name) is in {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} then
if (count file_name) = 1 then
set name of cur_file to "0" & character -1 of file_name & suf_fix
else if (character -2 of file_name) is not in {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} then
set name of cur_file to plain text 1 thru -2 of file_name & "0" & character -1 of file_name & suf_fix
end if
end if
end repeat
end tell
end open
33名称未設定:03/11/29 01:51 ID:pDrLkXiZ
メタファイル関連のスクリプトをもうひとつ
Windows Mediaの特定の箇所だけをリピート再生


on open file_list
tell application "Finder"
set wm_file to item 1 of file_list
set current_folder to container of wm_file
set start_time to (text returned of (display dialog "開始秒" default answer "0")) as integer
set start_time to "<starttime value=\"0:" & ((start_time div 60) as string) & ":" & ((start_time mod 60) as string) & "\"/>" & return
set duration_value to (text returned of (display dialog "再生秒数" default answer "30")) as integer
set duration_value to "<duration value=\"0:" & ((duration_value div 60) as string) & ":" & ((duration_value mod 60) as string) & "\"/>" & return
set repeat_count to (text returned of (display dialog "再生回数" default answer "3")) as integer
set repeat_count to "<repeat count=\"" & (repeat_count as string) & "\">" & return
set wvx_text to "<entry>" & return & start_time & duration_value & "<ref href=\"./" & name of wm_file & "\"/>" & return & "</entry>" & return
set wvx_text to "<asx version=\"3.0\">" & return & repeat_count & wvx_text & "</repeat>" & return & "</asx>"
set wvx_file to (make file with properties {creator type:"Ms01"} at current_folder) as alias
try
open for access wvx_file with write permission
write wvx_text to wvx_file
close access wvx_file
on error
close access wvx_file
end try
end tell
end open