0

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:

  1. Blender is set to not overwrite existing files as it creates new frame renders
  2. 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

  3. 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.

  • 1
    Please show us the research already done and add your brute force action as a hint what you want to do. – klanomath Oct 8 '16 at 10:55
  • Ok I'll add more description in the OP – Stephen Hamacek Oct 8 '16 at 13:16
  • OK, that's almost a different question ;-) though my answer is correct in regard to the original question... – klanomath Oct 8 '16 at 13:54
2

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:

FolderAction

Save it. The folder action will move all files smaller than 100 KB received in the folder "sort" to the Desktop folder.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .