2013-07-28 33 views
0

我正在下面的AppleScript:AppleScript的搜索路径进入POSIX路径

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路径(/用户/sam/Desktop/Resized/HighResCat.jpg)传递到自动机

++++++++++++ EDIT

I”我已经知道了这一点,但是当我需要所有的项目时,我只能通过列表中的一个项目。

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

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 
+0

'结果: 错误“系统事件出现错误:无法将文件”Macintosh HD:用户:sam:Desktop:Resized \“转换为整型。”从文件“Macintosh HD:用户:山姆:桌面:调整大小”到整数的-1700号码 – TagoMago

+0

每当我尝试将路径转换为POSIX时,表示它无法将“路径”转换为整数。 – TagoMago

+0

您是否正确地将输入设置为“/ Users/sam/Desktop/Resized”或者是否使用了将输入设置为POSIX文件“/ Users/sam/Desktop/Resized”'? – adayzdone