Moving files added to Desktop to Folder gives 0k files

I wrote a macro group I call AppWatcher, which watches for the addition of an application to the Applications folder. The macro watches for the addition of a new app, then automatically makes an alias and asks me to categorize it.

I had a problem very similar to yours, in that the aliases often failed to get created properly. And that's because, even though I wasn't moving files myself, I wanted my macro to trigger on the adding of a file to a folder. But that file, the app, consists of thousands of individual files, and watching for changes (even with the "ignore impartial files" option checked) would just fail.

I needed a way to make my macro wait until the install was really done. What I came up with in the end was this:

EDIT: Looking at this code now, the order is probably a bit wrong. The delay should move up between the two variable setting points, duh. I'll fix that in the 1.3 version of the macro. It still works now, but the delay is basically meaningless. Move it if you use something like this :).

I use two variables that track the size of the file as seen in the du command in Terminal. I set the oldSize equal to the newSize, delay for 0.8 seconds, check the newSize, then repeat the loop until the two numbers are equal. The delay value could probably be shorter, but I wanted to make sure I gave the OS enough time to get some copying done between checks.

I also display a randomized progress bar, just so I can see that the macro is still waiting on things to finish copying.

If you download the linked macro group, this routine is in the AppWatchAdd macro. For your uses, you'd watch the entire Desktop folder instead of a particular file:

du -s /Users/your_user/Desktop | egrep -Eo '\d+\t'

Once that value stops changing, there's no more copying going on.

-rob.