Applescript 将所有文件从 USB 复制到文件夹
Applescript Copy All File from USB to Folder
你能帮我使这个脚本工作吗?
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"
。 (没有名字是我的 USB 密钥。)
非常感谢您的帮助。
系统事件没有 "copy" 命令。你是在哪里拿到的?您可以试试 "move"。另外 "aVolume" 不是文件夹,是磁盘。您可能想将 "folder aVolume" 更改为 "disk aVolume"。你甚至可能需要使用 "disk (contents of 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
你能帮我使这个脚本工作吗?
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"
。 (没有名字是我的 USB 密钥。)
非常感谢您的帮助。
系统事件没有 "copy" 命令。你是在哪里拿到的?您可以试试 "move"。另外 "aVolume" 不是文件夹,是磁盘。您可能想将 "folder aVolume" 更改为 "disk aVolume"。你甚至可能需要使用 "disk (contents of 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