是AppleScript的处理在脚本运行时刻创建新的文件夹? [英] Is Applescript processing new folders that are created in the moment the script runs?

查看:260
本文介绍了是AppleScript的处理在脚本运行时刻创建新的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在上复制文件夹从一个AFP共享到本地文件夹,并做各种事情之后与这些文件夹的脚本。 (它删除复制后原始文件夹)

I am working on a script that duplicates folders from an afp share to a local folder and does all kind of things with those folders afterwards. (it deletes the original folders after duplicating)

这code是工作的罚款:

This code is working fine:

tell application "Finder"
duplicate every folder of folder afpFolder to localFolder with replacing
delete every folder of folder afpFolder
end tell

我的问题是我们的员工将加入新的文件夹, afpFolder regulary而且经常。我的脚本运行每隔10秒(用LaunchAgents),因为它需要尽可能多地处理该复制数据。

My problem is that our employees will be adding new folders to afpFolder regulary and quite often. My script is running every 10 seconds (with LaunchAgents) because it needs to process the duplicated data as often as possible.

我的问题是:当脚本复制和删除文件夹,并会发生什么在确切的同一时刻有人增加了一个新的文件夹 afpFolder

The question I have is: What happens when the script is duplicating and deleting folders and in the exact same moment somebody adds a new folder to afpFolder?

是否脚本只删除的内容在 afpFolder 在它开始运行时刻 或会不会是它会删除那些新建的一个而不重复它的文件夹?

Does the script only delete what was in afpFolder in the moment it started running or could it be that it would delete one of those newly created folders without duplicating it?

我也想过做什么用的列表。例如:

I have also thought about making something with a list. For example:

set folderList to {}
tell application "Finder" to set folderList to every folder of afpFolder
duplicate folderList to localFolder
delete folderList

(这可能不是以这种方式工作)

(this might not work this way)

谁能帮我回答这个问题?

Can anyone please help me answer the question?

我与上code,其中我只是复制和删除工作?还是我担心有关脚本删除了在脚本运行的瞬间创建的文件夹,而无需复制呢?

Can I work with the upper code where I just duplicate and delete? Or do I have to worry about the script deleting folders that are created in the moment the script runs, without duplicating them?

如果上code能制造麻烦,你可以帮我解决列表?

If the upper code can cause trouble, can you help me with the list solution?

推荐答案

第一个脚本会删除那些重复之间添加的项目和删除命令。但我想不出任何情况下,其中的第二种方法是行不通的:

The first script would delete items that are added between the duplicate and delete commands. But I can't think of any case where the second approach would not work:

tell application "Finder"
    set l to items of ((POSIX file "/private/tmp/test") as alias)
    duplicate l to desktop
    delete l
end tell

您也可以尝试用mv或rsync的:

You could also try using mv or rsync:

do shell script "mv /path/to/afp_folder/* /path/to/local_folder/"
do shell script "rsync -a /path/to/afp_folder/ /path/to/local_folder/
rm -r /path/to/afp_folder/*"

这篇关于是AppleScript的处理在脚本运行时刻创建新的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆