Skip to content

Instantly share code, notes, and snippets.

@lvsecoto
lvsecoto / get_selected_files_dirs_path.scpt
Created November 15, 2018 07:35 — forked from Teraflopst/get_selected_files_dirs_path.scpt
AppleScript:获取选中文件(夹)的目录路径
-- 脚本介绍
-- 功能:获取所选文件、文件夹的目录路径,支持多选
-- 如果仅仅想获取文件的目录路径,可以调用 isDirectory() 过滤掉文件夹的路径
tell application "Finder" to set selectedItems to selection as alias list
-- 没选择的话直接退出脚本
if selectedItems is {} then return
-- 获得所选文件/文件夹的父目录。
set parentPath to do shell script "dirname " & quoted form of POSIX path of (item 1 of selectedItems)
-- 用于拼接多个路径