我收到有关无法将别名...设为整数的错误?不确定...
我正在尝试使此代码段包含几个文件夹(每个文件夹中都有一堆图像),然后将内容复制到存档驱动器。
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
代码中有很多问题。
最重要的是
droppedItems
是文件列表。要获得名称,您必须使用一个文件duplicate
命令属于Finder。它必须包装在tell application "Finder"
块中。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