【问题标题】:Applescript: check if active finder window path contains certain name to change a varApplescript:检查活动查找器窗口路径是否包含特定名称以更改 var
【发布时间】:2017-02-01 02:59:03
【问题描述】:
我需要一个脚本来查看当前活动的查找器窗口路径并检查路径是否包含名称。如果找到某个名称,则应将另一个变量更改为其他名称。
告诉应用程序“Finder”
将 currentDirectory 设置为 Finder 窗口 1 的目标
结束告诉
将 myVar 设置为“某物”
将 myVar2 设置为“xxx”
如果 currentDirectory 包含 myVar 则将 myVar2 设置为“其他”
【问题讨论】:
标签:
macos
path
applescript
finder
【解决方案1】:
请试试这个代码,让我知道它是否适合你:
set myVar1 to "Users"
set myVar2 to "2"
set myVar3 to "3"
tell application "Finder"
set thePath to (POSIX path of (target of window 1 as alias))
if thePath contains myVar1 then
set myVar2 to myVar3
end if
end tell