我正在编写一个 Apple 脚本,最终将为 EyeTV 的所有 iTunes 导出标记广告。但我遇到了 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
别名“Macintosh HD2:文档:EyeTV Archive:South Park.eyetv:000000001613eaa6.eyetvr”
现在我需要提取包含路径和文件前缀 000000001613eaa6 (使用这个问题 https://stackoverflow.com/questions/4278704/applescript-get-filenames-in-folder-without-extension)这样我就可以在文件 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”的磁盘“Macintosh HD2”的文件夹“Documents”的文件夹“EyeTV Archive”的文档文件“South Park.eyetv”
root_name: "000000001613eaa6.eyetvr"
fext: ""
fext 应该是“.eyetvr”,而不是空字符串。如何从 eyetvr_file 或 root_name 中正确提取“.eyetvr”?我尝试过很多类似的黑客行为
set fext to name extension of (eyetvr_file as document)
但这会产生错误,例如
错误“无法将别名 \“Macintosh HD2:Documents:EyeTV Archive:South Park.eyetv:000000001613eaa6.eyetvr\”创建为类型文档。”编号 -1700,从别名“Macintosh HD2:Documents:EyeTV Archive:South Park.eyetv:000000001613eaa6.eyetvr”到文档
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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)