2013-04-26 46 views
0

我有一些我希望使其具有通用性的例程:代替选定的文件夹,我想在描述文件夹时粘贴到用户当前用户(“〜/”)路径..Automator“Get specified finder items”applescript equivalent

所以我的问题是,如果我在automator中选择一个带有“Get Specified Finder Items”的文件夹,那么会输出如下所示的一个-non applescript-list :(“path/to/my/folder”),我怎样才能用applescript复制它。注意圆括号而不是大括号!

首先,我只是想用这个:

on run 
    return {"~/path/to/my/folder/under/current/user"} 
end run 

然后我想补充“获取文件夹目录”块..

谁能告诉我为什么会不工作? 在此先感谢!

+0

当然,还有将在多个文件夹中的UNIX类路径列表..这就是为什么我首先需要一个列表。 – ppseprus 2013-04-26 13:23:58

回答

1

嗯,我还不如寄我是为你反正:-)

set folderTest1 to "test1" 
set folderTest2 to "test2" 


set homePath to POSIX path of (path to home folder as text) as text 
set attachmentsFolder to (homePath & folderTest1 & "/" & folderTest2) as text 

--OR 


set homePath to POSIX path of (path to home folder as text) as text 
set attachmentsFolder to (homePath & "test1/test2") as text 

POSIX PATH打字改变HFS +路径到一个unix类型路径

路径到家文件夹到达用户主文件夹

路径文件获取路径到用户文件夹

POSIX文件变成一个HFS +路径

set homePath to POSIX path of (path to home folder as text) as text 


set theHFSPath to (POSIX file homePath) 
tell application "Finder" 
    --The finder looks for the folders in the alais path of theHFSPath 
    set theFolders to folders of (theHFSPath as alias) as alias list 

    --> returns is a list of folders in the form of alais paths 

end tell 
+0

我最终用下面的语法解决了它: 'return {alias((作为文本的主文件夹的路径)&“Library:Caches:Adobe Camera Raw”)}' Ans since this was in“Run AppleScript“块,我只是附加”获取文件夹内容“和”移动Finder物品到垃圾“块。这种方式是普遍的,我可以将它发送给同事。 – ppseprus 2013-04-28 15:06:07

0

我用下面的代码解决了这个问题:

on run 
return { POSIX path of ((path to home folder as text)) & "/path to my folder" as text, .. } 
end run 
+1

它可以缩写为'{(系统属性“HOME”)&“/我的文件夹路径}}。脚本有一个隐式运行处理程序,它们返回最后一个值。 '系统属性“HOME”'与$ HOME相同。 – user495470 2013-04-26 19:45:54

+0

我最终用下面的语法解决了它:''作为文本返回{别名((作为文本的主文件夹的路径)&“Library:Caches:Adobe Camera Raw”)}'因为这是在“运行AppleScript”块我的automator应用程序,我只是附加“获取文件夹内容”和“移动Finder项目toTrash”块。这种方式是普遍的,我可以将它发送给同事。 – ppseprus 2013-04-28 15:16:21