AppleScript的查找路径为POSIX路径 [英] Applescript Finder path into POSIX path

查看:671
本文介绍了AppleScript的查找路径为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的查找路径为POSIX路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆