Applescript 从列表连接POSIX文件路径

Applescript 从列表连接POSIX文件路径,applescript,posix,rsync,Applescript,Posix,Rsync,我有一个带有文件夹路径的列表,该列表应该正确连接,以便使用rsync命令将多个源文件夹备份到单个源文件夹中 这就是我到目前为止所做的: set sourcefolderlist to {"/Volumes/sourcefolder1", "/Volumes/sourcefolder2"} set localfolder to quoted form of POSIX path of ("/Users/dfdfdf/destinationfolder") set allSourceFolder

我有一个带有文件夹路径的列表,该列表应该正确连接,以便使用
rsync
命令将多个源文件夹备份到单个源文件夹中


这就是我到目前为止所做的:

set sourcefolderlist to {"/Volumes/sourcefolder1", "/Volumes/sourcefolder2"}
set localfolder to quoted form of POSIX path of ("/Users/dfdfdf/destinationfolder")

set allSourceFolders to ""
repeat with oneSourceFolder in sourcefolderlist
    set allSourceFolders to ((quoted form of POSIX path of allSourceFolders) & oneSourceFolder)
end repeat
因此,源路径应该位于一个列表中,该列表与POSIX文件路径(如
localfolder
)连接起来。
结尾应该是这样的:

do shell script "rsync -arvuE " & allSourceFolders & " " & localfolder
如何连接
sourcefolderlist
中的项目,以便
rsync
可以读取正确的POSIX文件夹路径?

从手册页:

rsync [OPTION]... SRC [SRC]... DEST
我想你只是用一个“”字符把它们分开

如果您仍然需要一个列表作为所有源的源(很方便),请按如下方式循环:

set sourcefolderlist to {"/Volumes/sourcefolder1", "/Volumes/sourcefolder2"}
set localfolder to quoted form of POSIX path of ("/Users/dfdfdf/destinationfolder")

set sources to ""
repeat with i from 1 to number of items in sourcefolderlist
    set sources to sources & " " & quoted form of (item i of sourcefolderlist as text)
end repeat

log sources -- > (* '/Volumes/sourcefolder1' '/Volumes/sourcefolder2'*)

do shell script "rsync -arvuE " & sources & " " & localfolder

顺便说一句:使用AppleScript的内置代码段:创建新行,将“sourcefolderlist”(=包含列表的变量)粘贴到新行中,然后按CTRL键单击它。选择“Repeat Routines”并从中选择“Process every item”。

我编写了一个Applescript脚本库()来帮助连接Applescript列表项,在列表项中,您还可以在最后一个字符串中添加引号

这种情况下的使用示例如下:

        #Needed Use Clauses
    use script "you Library name here"
    --use scripting additions

    set sourcefolderlist to {"/Volumes/sourcefolder1", "/Volumes/sourcefolder2"}
    set sources to join list items sourcefolderlist using text space with items in single quotes

-- Result--> "'/Volumes/sourcefolder1' '/Volumes/sourcefolder2'"
在第1版的帖子中也有一个小标题。它还有指向Applescript脚本库上的Apple会话的链接