Applescript Finder 路径到 POSIX 路径 [英] Applescript Finder path into POSIX path
本文介绍了Applescript Finder 路径到 POSIX 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行以下 AppleScript:
I'm running the following 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
它正在正常工作,但它正在返回:
It's working as it should, though it's returning:
{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
where I need a POSIX path (/Users/sam/Desktop/Resized/HighResCat.jpg) to pass to automator
++++++++++++ 编辑
++++++++++++ EDIT
到目前为止,我已经完成了,但是当我需要所有项目时,我一次只能传递列表中的一项.
I've got it this far, but I can only pass one item of the list at a time when I need all of the items.
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
I converted to a string and on return converted to POSIX
++++++++++EDIT2
+++++++++EDIT2
这个脚本在 automator 内部工作:
This script worked inside 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
谢谢
推荐答案
尝试:
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
这篇关于Applescript Finder 路径到 POSIX 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文