【问题标题】:Applescript Finder path into POSIX pathApplescript Finder 路径到 POSIX 路径
【发布时间】:2013-07-28 17:22:13
【问题描述】:

我正在运行以下小程序:

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) 来传递给自动机

++++++++++++++编辑

到目前为止,我已经掌握了它,但是当我需要所有项目时,我一次只能传递列表中的一项。

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

这个脚本在自动机中工作:

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

谢谢

【问题讨论】:

    标签: path applescript finder


    【解决方案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
    

    【讨论】:

    • Result: error "System Events got an error: Can’t make file \"Macintosh HD:Users:sam:Desktop:Resized\" into type integer." number -1700 from file "Macintosh HD:Users:sam:Desktop:Resized" to integer
    • 每次我尝试将路径转换为 ​​POSIX 时都说它无法将“路径”转换为整数。
    • 你复制的代码是set input to "/Users/sam/Desktop/Resized"还是使用set input to POSIX file "/Users/sam/Desktop/Resized"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-07
    • 2010-11-06
    • 1970-01-01
    • 1970-01-01
    • 2014-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多