I'm trying to set up a folder action that triggers only when a new file is less than a certain size. With my limited understanding I haven't been able to figure out a way to do this. Can anyone help?
Here's a run-down of my problem and my current approach: I'm doing some 3D rendering in Blender through the command line in Terminal, but having a persistent error. Blender renders each frame's image, but after usually 3 or 4 frames of animation rendering, the GPU bombs out and all the subsequent frames render black with a size of 28kB.
My brute force method of remedying this so I can render unattended:
- Blender is set to not overwrite existing files as it creates new frame renders
-
Automator Folder Action whenever a new frame is saved:
on run {input, parameters}
-- ignoring application responses tell application "Keyboard Maestro Engine" do script "BA8776AB-5030-4753-85FB-0032D396B9B1" -- or: do script "renderhack" end tell -- end ignoring return input
end run
-
This triggers a Keyboard Maestro macro which does the following:
3a. Activates Terminal Window
3b. Types Ctrl-C keystroke to kill Blender process (it's already started rendering next frame)
3c. Executes a shell script to delete any small files i.e.
find -name "*.png" -size -1M -delete
(this is unnecessary for now but would be if I could solve my problem)
3d. Reactivates Terminal Window
3e. Types Up-arrow key, Return to relaunch blender in the Terminal.
So this does work, but I would love to find a more elegant solution, which would save a few more seconds every frame. If the folder action could work conditionally somehow, to only trigger the next script/macro if the most recent file is a certain size.
I hope this makes sense. Unfortunately just moving small files out of the folder doesn't work, since Blender will keep rendering black frames. I need to trigger the above steps (or something like it that also includes killing Blender) when a small file appears in the folder.
Best Answer
You can use Automator to create a folder action which filters Finder items like this:
Choose "Folder Action" in the start screen of Automator and create a workflow similar to this one:
Save it. The folder action will move all files smaller than 100 KB received in the folder "sort" to the Desktop folder.