Applescript Finder path into POSIX path

泪湿孤枕 提交于 2019-12-12 10:17:09

问题


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"}

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)

I converted to a string and on return converted to POSIX

+++++++++EDIT2

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

thanks


回答1:


Try:

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


来源:https://stackoverflow.com/questions/17910790/applescript-finder-path-into-posix-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!