text 在路径查找器中选择的Finder项目中显示(AppleScript)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 在路径查找器中选择的Finder项目中显示(AppleScript)相关的知识,希望对你有一定的参考价值。

--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
on revealPFItemInFinder()
  --–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  (*  VER: 2.1    2018-03-19
    PURPOSE:  Reveal Item in Finder that is Selected in Path Finder
         
    RETURNS:  alias of item selected in both Finder and Path Finder
                  
    AUTHOR:  JMichaelTX
  --–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  *)
  local finWinName, pfWinName, fileList, itemPath, oItem
  
  --- GET THE ITEM SELECTED IN PATH FINDER ---
  
  tell application "Path Finder"
    set fileList to (get selection)
    if ((fileList is missing value) or ((count of fileList) ≠ 1)) then error ("You must select only ONE file in Path Finder.")
    set oItem to item 1 of fileList
    set itemPath to POSIX path of oItem
    set pfWinName to name of container of oItem
  end tell
  
  set itemAlias to alias POSIX file itemPath
  
  --- REVEAL SAME ITEM IN FINDER ---
  
  tell application "Finder"
    activate -- to make sure reveal will be in frontmost window
    reveal itemAlias
    
    --- Now Wait for New Finder Window with Same Name as Path Finder ---
    
    set finWinName to name of window 1
    
    set maxWaitTime to 2.0
    set delayTime to 0.1
    set waitTime to 0
    
    repeat while finWinName ≠ pfWinName
      delay delayTime
      set finWinName to name of window 1
      set waitTime to waitTime + delayTime
      if (waitTime > maxWaitTime) then error "Max wait time of " & maxWaitTime & " exceeded waiting for Finder Window of " & pfWinName
    end repeat
    
  end tell
  
  return itemAlias
  
end revealPFItemInFinder

以上是关于text 在路径查找器中选择的Finder项目中显示(AppleScript)的主要内容,如果未能解决你的问题,请参考以下文章

从我的应用程序中查找finder中的放置位置

006-mac下finder操作

从列表或元组中显式选择项目

创建的组文件夹在 xcode 的 finder 中显示不可见

Mac 日常使用问题收集

Mac 日常使用问题收集