Applescript Finder路径进入POSIX路径

时间:2013-07-28 17:22:13

标签: path applescript finder

我正在运行以下AppleScript:

tell application "Finder"
set input to POSIX file "/Users/sam/Desktop/Resized"
set theFiles to (every file of folder input whose name does not contain "- Resized")
end tell

return theFiles

尽管它正在回归,但它仍在运作:

{document file "HighResCat.jpg" of folder "Resized" of folder "Desktop" of folder "sam" of    folder "Users" of startup disk of application "Finder", document file "madonna.jpg" of folder "Resized" of folder "Desktop" of folder "sam" of folder "Users" of startup disk of application "Finder"}

我需要一个POSIX路径(/Users/sam/Desktop/Resized/HighResCat.jpg)传递给automator

++++++++++++++++++++ + + + + +

我已经达到了这个目的,但我只能在需要所有项目的时候传递列表中的一项。

tell application "Finder"
    set input to POSIX file "/Users/sam/Desktop/Resized"
    set theFiles to (every file of folder input whose name does not contain "-  Resized")
set input to item 1 of theFiles as string
end tell


return (POSIX file input)

我转换为字符串,并在返回时转换为POSIX

+++++++++ EDIT2

此脚本在automator中运行:

on run {input, parameters}
set input to (input) as string
tell application "System Events" to set theFiles to POSIX path of (files of folder    input whose name does not contain "- Resized")
set input to theFiles
return input
end run

感谢

1 个答案:

答案 0 :(得分:1)

尝试:

set input to "/Users/sam/Desktop/Resized"
tell application "System Events" to set theFiles to POSIX path of (files of folder input whose name does not contain "- Resized")
return theFiles