你可以尝试这样的事情:
set destinFolder to (choose folder)
set destItems to every paragraph of (do shell script "ls " & quoted form of (POSIX path of destinFolder))
tell application "Finder"
set mySelection to selection
repeat with anItem in mySelection
set itemName to anItem's name
if itemName is in destItems then
display alert "An item named " & itemName & " already exists in this location. Do you want to replace it with the one you're moving?" buttons {"Skip", "Replace"} default button "Replace"
if button returned of the result = "Replace" then move anItem to destinFolder with replacing
else
try
move anItem to destinFolder
end try
end if
end repeat
end tell
或这个:
set destinFolder to (choose folder)
tell application "Finder"
set mySelection to selection
repeat with anItem in mySelection
try
move anItem to destinFolder
on error errMsg number errNum
if errNum = -15267 then
display alert "An item named " & itemName & " already exists in this location. Do you want to replace it with the one you're moving?" buttons {"Skip", "Replace"} default button "Replace"
if button returned of the result = "Replace" then move anItem to destinFolder with replacing
else
tell me
activate
display alert errMsg & return & return & "Error number" & errNum buttons "Cancel"
end tell
end if
end try
end repeat
end tell
编辑此脚本不会让您选择目标文件夹中存在的每个项目
set destinFolder to (choose folder)
tell application "Finder"
set mySelection to selection
try
move mySelection to destinFolder
on error errMsg number errNum
if errNum = -15267 then
display alert "One or more items already exist in this location. Do you want to replace them with the ones you're moving?" buttons {"Skip", "Replace"} default button "Replace"
if button returned of the result = "Replace" then move mySelection to destinFolder with replacing
else
tell me
activate
display alert errMsg & return & return & "Error number" & errNum buttons "Cancel"
end tell
end if
end try
end tell