请帮助,我无法解决此问题。
文件夹操作是为复制到文件夹中的每个文件执行此操作:
文件从不同的卷复制,通常为500 ... 1500 MB。
问题:文件夹操作脚本中的移动步骤(步骤3)如果文件很大且编号为>1
则会失败
它们是从不同的卷中复制的。
复制时脚本可以正常工作:小文件,或来自同一卷,或只有一个文件。
在一次测试中,所有200个Alias'已正确处理,但只有312中的23个。这不是问题,added_items
的数量通常是<10
,不太可能是>50
。但它可能有助于解决这个问题。
我怀疑是时间问题,但所有尝试使用慷慨的timeout
修复它都没有用。
脚本(注意 - 在尝试之前,将do shell script
行中的正则表达式设置为可行的东西):
on adding folder items to this_folder after receiving added_items
repeat with the_item in added_items
with timeout of 3600 seconds
tell application "Finder"
if kind of the_item is not "Folder" then
repeat -- wait until item is copied. Thanks to original coder on the WWW.
set {size:fileSize, busy status:Busy} to (info for (the_item))
if not Busy and (fileSize is greater than 0) then exit repeat
delay 1
end repeat
with timeout of 600 seconds
set new_folder_name to do shell script "echo '" & (name of the_item) ¬
& "' | sed -E 's/llooongRegex/replace/g'"
set new_item_name to do shell script "echo '" & (name of the_item) ¬
& "' | sed -E 's/otherRegex/replace/g'"
set new_folder to (make new folder at this_folder with properties {name:(new_folder_name & "-temp")}) as alias -- "-temp" in case new folder and file will have the same name
move file the_item to folder new_folder -- <== fails if ((added_items >1) AND (files big, tested with 0.5…1.5GB) AND (copied from different volume)) ==> Timing issue?
set name of (first item of (get contents of new_folder)) to new_item_name
set name of new_folder to new_folder_name
end timeout
end if
end tell
end timeout
end repeat
end adding folder items to
P.S。:folder-action
频繁到标签?
答案 0 :(得分:0)
用简单的repeat -- wait until item is copied....
替换delay 60
子句后,脚本可以正常工作。所以这是一个时间问题。
等待目标文件夹停止更改大小,因为描述here只要只运行1个文件复制(丢弃一堆文件)就可以工作。两次或多次拖动,再次打嗝(好消息,@ vadian!)。
同时检查单个添加项目的大小以保持不变。