我收到一个关于无法将别名...变成整数的错误?不确定...
我正在尝试使此片段包含几个文件夹(每个文件夹中都有一堆图像)并将其内容复制到存档驱动器。
on open droppedItems
set user to do shell script "whoami"
set archivePath to "/Users/" & user & "/Desktop/Archive' 'Drive"
#tell application "Finder" to set jobName to name of item droppedItems
#I need to figure this out as it's not working the way I originally had it
tell application "Finder"
do shell script "mkdir -p " & archivePath & "/" & jobName & "RAW' 'FILES"
set localDestination to archivePath & "/" & jobName & "RAW' 'FILES"
do shell script "open " & localDestination
activate
set position of window 1 to {1000, 0}
end tell
**#this is where I'm having issues (obviously)**
repeat with i from 1 to count of droppedItems
set currentItem to item i of droppedItems
#display dialog (currentItem)
duplicate currentItem to localDestination #I've tried a few different things here...
end repeat
end open
答案 0 :(得分:1)
代码中有很多问题。
最重要的是
droppedItems
是项目的列表。要获得名称,您必须使用一项。do shell script
行中,路径以quoted form of
进行转义。duplicate
命令属于Finder。它必须包装在tell application "Finder"
块中。“查找器”窗口不相关。您可以在没有打开窗口的情况下复制项目。但是我添加了一行来打开文件夹。而且您也不需要重复循环。
on open droppedItems
set archivePath to (path to desktop as text) & "Archive Drive"
tell application "Finder" to set jobName to name of first item of droppedItems
set localDestination to archivePath & ":" & jobName & "RAW FILES"
do shell script "mkdir -p " & quoted form of POSIX path of localDestination
tell application "Finder"
duplicate droppedItems to folder localDestination
open folder localDestination
end tell
end open
如果您只想复制文件夹的内容,则确实需要重复循环
on open droppedItems
set archivePath to (path to desktop as text) & "Archive Drive"
tell application "Finder" to set jobName to name of first item of droppedItems
set localDestination to archivePath & ":" & jobName & "RAW FILES"
do shell script "mkdir -p " & quoted form of POSIX path of localDestination
tell application "Finder"
repeat with anItem in droppedItems
if class of anItem is folder then
duplicate every item of anItem to folder localDestination
else
duplicate anItem to folder localDestination
end if
end repeat
open folder localDestination
end tell
end open