Applescript将所有文件从USB复制到文件夹

时间:2015-01-27 14:19:25

标签: applescript

你能帮助我让这个脚本工作吗?

property ignoredVolumes : {"DD APPLE", "MobileBackups"} 
tell application "System Events"

set Destination_Folder to folder "/Users/Joseph/Downloads/Test" of startup disk
set rootVolume to disk item (POSIX file "/Volumes" as text)
set allVolumes to name of every disk item of rootVolume

repeat with aVolume in allVolumes
    if aVolume is not in ignoredVolumes then
        copy every item of folder (aVolume) to Destination_Folder
    end if
end repeat
end tell

问题出在copy every item of folder (aVolume) to Destination_Folder行 - 我收到的错误消息是Can’t get every file of "NO NAME"。 (No Name是我的USB密钥。)

非常感谢你的帮助。

1 个答案:

答案 0 :(得分:0)

系统事件没有"副本"命令。你是在哪里拿到的?你可以试试"移动"代替。加上" aVolume"不是文件夹,它是一个磁盘。您可能想要更改"文件夹aVolume" to" disk aVolume"。您甚至可能需要使用"磁盘(aVolume的内容)"

编辑 :尝试以下脚本。我没有测试它,但它应该工作。祝你好运。

property ignoredVolumes : {"DD APPLE", "MobileBackups", "home", "net"} -- leave home and net in this list
set Destination_Folder to ((path to downloads folder as text) & "Test:") as alias

set mountedVolumes to list disks

repeat with i from 1 to count of mountedVolumes
    set thisVolume to item i of mountedVolumes
    if thisVolume is not in ignoredVolumes then
        tell application "Finder"
            set theItems to items of disk thisVolume
            move theItems to Destination_Folder
        end tell
    end if
end repeat