【发布时间】:2011-11-28 21:47:59
【问题描述】:
我想知道如何从字符串中只返回文件扩展名。我尝试了this 问题中详述的“将变量设置为...的扩展名”,但这似乎只适用于公认的扩展名。这个想法是将扩展名为“.meta”的文件分类到他们自己的集合中。
我现在的样子
tell application "Finder'
set everyName to name of every item in entire contents of this_folder
end tell
set metaFiles to {}
repeat with n from 1 to count of everyName
set currentName to item n of everyName
set currentExt to last word of currentName --this assignment fails
if currentExt is "meta" then
set end of metaFiles to currentExt
end if
end repeat
我是 applescript 的新手,所以我很感激任何和所有的帮助/指导。谢谢!
编辑:Hacky 解决方案
我通过使用here 描述的拆分函数在每个句点后分解文件名来解决这个问题。我抓住最后一个字符串,确保它与第一个字符串不同,以防没有句点字符,然后存储相应的文件名。
【问题讨论】:
标签: applescript filenames string-parsing