2010年4月28日 星期三

Display Localized Directory Name on Mac OS X

如果你想建立一個目錄
並希望目錄名稱可以隨著『不同的系統語言設定』而『顯示不同的名稱』
範例:目錄 Work,在中文環境下顯示『工作』
步驟如下
1. change directory "Work" to "Work.localized"
2. create a diectory ./Work.localized/.localized
3. create a file ./Work.localized/.localized/en.strings

"Work" = "Work";

4. create a file ./Work.localized/.localized/zh_TW.strings

"Work" = "工作";

2010年4月27日 星期二

Display Localized Directory Name on Mac OS X

如果你想建立一個目錄
並希望目錄名稱可以隨著『不同的系統語言設定』而『顯示不同的名稱』
範例:目錄 Work,在中文環境下顯示『工作』
步驟如下
1. change directory "Work" to "Work.localized"
2. create a diectory ./Work.localized/.localized
3. create a file ./Work.localized/.localized/en.strings

"Work" = "Work";

4. create a file ./Work.localized/.localized/zh_TW.strings

"Work" = "工作";

2010年4月22日 星期四

自動影片分割

因為要上傳影片到 Youtube
必須將影片分割成數個不超過10分鐘長度的小片段
可是在 Mac OS X 下好像沒有好用的軟體
可又不想用 Quicktime 來一個一個手動分割
所以參考了一些資料後
寫了一個 AppleScript
File name : splite.scpt
[sourcecode language="text"]
(*
Splite Quicktime Movie into equally sized for Youtube
YF Chen
yfc@yfchen.com
*)

set sourceFile to choose file with prompt "choose video file as source"
set theFolder to (choose folder with prompt "Choose a folder for the slices:") as text

tell application "Finder"
my splitteVideo(sourceFile, theFolder)
end tell

on splitteVideo(sourceFile, theFolder)

tell application "QuickTime Player 7"
activate
try
open sourceFile
on error
display dialog "Open a movie first" buttons ["OK"] with title "Error"
return
end try

-- get active movie
set sourceDoc to document 1
set theDuration to duration of sourceDoc
set theTitle to name of sourceDoc
set DurOverlap to 2 -- 2sec overlaping
set DurScal to (90 * 1000)

-- calculate segments
set DurCut to (9 * 60) -- 9 min
set DurDoc to (duration of sourceDoc) / DurScal
set NumOfSeg to DurDoc div DurCut

-- loop each segment
repeat with i from 0 to NumOfSeg
-- set segment selection
set durStart to (i * DurCut) * DurScal
set durEnd to ((i + 1) * DurCut + DurOverlap) * DurScal
if durEnd > theDuration then
set durEnd to theDuration
end if
set selection start of sourceDoc to durStart
set selection end of sourceDoc to durEnd
-- copy selection into new movie
copy sourceDoc
set newdoc to make new document
paste newdoc
set theSlice to i as integer as string
set theFile to (theTitle & "_" & theSlice) & ".mov" as string
set theFile_full to (theFolder & theFile) as string
try
save self contained newdoc in theFile_full
end try
close document theFile
end repeat

close sourceDoc
quit

end tell

end splitteVideo
[/sourcecode]

自動影片分割

因為要上傳影片到 Youtube
必須將影片分割成數個不超過10分鐘長度的小片段
可是在 Mac OS X 下好像沒有好用的軟體
可又不想用 Quicktime 來一個一個手動分割
所以參考了一些資料後
寫了一個 AppleScript

(*
Splite Quicktime Movie into equally sized for Youtube
YF Chen
yfchen58i@gmail.com
*)

set sourceFile to choose file with prompt "choose video file as source"
set theFolder to (choose folder with prompt "Choose a folder for the slices:") as text

tell application "Finder"
my splitteVideo(sourceFile, theFolder)
end tell

on splitteVideo(sourceFile, theFolder)
tell application "QuickTime Player 7"
activate
try
open sourceFile
on error
display dialog "Open a movie first" buttons ["OK"] with title "Error"
return
end try

-- get active movie
set sourceDoc to document 1
set theDuration to duration of sourceDoc
set theTitle to name of sourceDoc
set DurOverlap to 2 -- 2sec overlaping
set DurScal to (90 * 1000)

-- calculate segments
set DurCut to (9 * 60) -- 9 min
set DurDoc to (duration of sourceDoc) / DurScal
set NumOfSeg to DurDoc div DurCut

-- loop each segment
repeat with i from 0 to NumOfSeg

-- set segment selection
set durStart to (i * DurCut) * DurScal
set durEnd to ((i + 1) * DurCut + DurOverlap) * DurScal
if durEnd > theDuration then
set durEnd to theDuration
end if
set selection start of sourceDoc to durStart
set selection end of sourceDoc to durEnd

-- copy selection into new movie
copy sourceDoc
set newdoc to make new document
paste newdoc

set theSlice to i as integer as string
set theFile to (theTitle & "_" & theSlice) & ".mov" as string
set theFile_full to (theFolder & theFile) as string

try
save self contained newdoc in theFile_full
end try

close document theFile

end repeat

close sourceDoc
quit

end tell

end splitteVideo