3

私は、EyeTVからのすべてのiTunesエクスポートのコマーシャルを最終的にマークするAppleScriptを書いています。しかし、私はAppleScriptパスで単純な問題に遭遇しています。これは、EyeTVアプリが記録場所として返します。コンテキストは次のとおりです。

set recordingID to 370404006
set myid to recordingID as integer
tell application "EyeTV"
    set eyetvr_file to get the location of recording id myid as alias
end tell
return eyetvr_file

エイリアス「MacintoshHD2:ドキュメント:EyeTVアーカイブ:サウスパーク.eyetv:000000001613eaa6.eyetvr」

次に、含まれているパスとファイルプレフィックス000000001613eaa6を抽出する必要があります(この質問を使用)。これにより、ファイル000000001613eaa6.edlで対応する商用マーキングを探すことができます。しゃっくりは次のとおりです。

tell application "Finder"
    set eyetv_path to container of eyetvr_file
    set root_name to name of eyetvr_file
    set fext to name extension of eyetvr_file
end tell

結果は、

eyetv_path:アプリケーション「Finder」のディスク「MacintoshHD2」のフォルダ「Documents」のフォルダ「EyeTVArchive」のドキュメントファイル「SouthPark.eyetv」

root_name: "000000001613eaa6.eyetvr"

fext: ""

fextは、空の文字列ではなく、「。eyetvr」である必要があります。eyetvr_fileまたはroot_nameから「.eyetvr」を正しく抽出するにはどうすればよいですか?私は次のようなハックをたくさん試しました

set fext to name extension of (eyetvr_file as document)

しかし、これは次のようなエラーをもたらします。

エラー「エイリアス\"MacintoshHD2:Documents:EyeTV Archive:South Park.eyetv:000000001613eaa6.eyetvr\"をタイプドキュメントにできません。」エイリアス「MacintoshHD2:Documents:EyeTV Archive:South Park.eyetv:000000001613eaa6.eyetvr」からドキュメントへの番号-1700

4

2 に答える 2

1

Finder は、すべてのファイル拡張子を認識するわけではありません。ただし、テキスト項目の区切り記号を使用して最後の部分を削除することもできます。

do shell script "touch /tmp/some.file.eyetvr"
set text item delimiters to "."
tell application "Finder"
    set n to name of file (POSIX file "/tmp/some.file.eyetvr")
    if n contains "." then set n to (text items 1 thru -2 of n) as text
    n -- some.file
end tell
于 2012-10-16T05:26:57.283 に答える
1

ミニコメントでは明らかにコードの投稿が許可されていないため、Lauri Ranta の素敵なソリューションを編集したものを次に示します。

do shell script "touch /tmp/some.file.eyetvr"
set delims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
tell application "Finder"
    set n to name of file (POSIX file "/tmp/some.file.eyetvr")
    if n contains "." then set n to (text items 1 thru -2 of n) as text
    n -- some.file
end tell
set AppleScript's text item delimiters to delims

プロジェクトが完了したら、EyeTV-commercial-marking-script-for-iOS へのリンクを投稿します。

于 2012-10-16T14:35:29.873 に答える