Folder Trigger and Copying a Folder Into a Folder

I've got a folder, let's call it "Active" that I sync daily to a few places as a backup, this folder contains projects being actively worked on in the past 30 days. I've got other folders which contain projects that haven't been worked on in the last 30 days, and after a certain period of time, these projects get offloaded from the primary storage. Sometimes, i'll have to "re-activate" a project, so it gets copied back into the "Active" folder. I'd like to automate moving the duplicated copies of that same folder into the sync'd "Active" folders in the other locations.

So I've been testing trying to use the "Folder Trigger" on my "Active" folder, so if i copy an old project to this folder, KM will search the list of folders on my backup locations, and if it finds it, it will move the project into the "Active" backup folders, so that i'm not needlessly syncing data that already exists over my WAN daily.

I set up the macro and it works great, the only problem is, if i'm copying a folder full of files, even using the "ignore partial files" the folder trigger gets triggered when the folder is finished copying, so what ends up happening is that the source folder i'm copying it from is moved before it can finish copying. I think the folder trigger is probably insufficient for this task after reading the wiki, but would love some other ideas on how I might wait until the folder has fully copied to execute the move commands.

You're going to have check the parent folder and contents and pause until there are no more changes. Two ways of doing that would be to get the size of the entire contents of the parent folder every second until the size no longer changes using du, or to look for open files with the parent folder as part of their path using lsof.

For lsof, probably the most reliable method, see @peternlewis's post here and the follow-on discussion.

3 Likes

Thanks!!! Adding this worked: (Project_to_Copy is just set to %TriggerValue%)

image

1 Like

Great! But I suggest you lose the h argument and just use du -s -- you don't need human-readable, and with larger projects there's a chance you'll miss a change because of the reduced precision.

3 Likes

Great point, i'm just so used to using the h argument with du i didn't even consider that. Thank you

1 Like