Applescript将文件从挂载的磁盘复制到主磁盘上的文件夹

时间:2013-06-18 21:59:55

标签: applescript

这是我第一次尝试使用AppleScript。我尝试使用已知的已安装设备(在本例中为Olympus录音机),文件数量不明,并将其从设备复制到Macintosh HD上的特定文件夹。我写了一个简短的脚本,告诉finder检查设备和文件夹,然后将文件夹中的文件名放入变量中。然后foreach循环遍历列表,并且应该将文件复制到最终的休息位置......结果是错误"无法获得Current_File ..."其中Current_File是File_List变量的当前迭代。

这里是脚本(注释掉的行试图隔离错误): *

tell application "Finder"
    if folder "DSS_FLDA" of disk "Untitled" exists then
        set File_List to files of folder "DSS_FLDA" of disk "Untitled"
        local Current_file
        foreach(Current_file in File_List)
            #Print Current_File
            copy file Current_file to folder "User:wt:DSSPlayer:Message:FolderA" of startup disk
    else
        return 0
    end if

    #first item of folder "DSS_FLDA" of disk "Untitled"
end tell

*

任何有更多Applescript经验的人都能指出我更有成效的方向吗?

谢谢, 丹尼尔。

1 个答案:

答案 0 :(得分:0)

您可以使用duplicate命令或只使用cp:

tell application "Finder"
    try
        duplicate items of folder "DSS_FLDA" of disk "Untitled" to POSIX file "/Users/wt/DSSPlayer/Message/FolderA" replacing yes
    on error
        --
    end try
end tell
do shell script "[[ -e /Volumes/Untitled/DSS_FLDA ]] && cp /Volumes/Untitled/DSS_FLDA/ ~/DSSPlayer/Message/Folder"
相关问题