-1

I have script in bash called "Nautilus Script". It can be executed from system folders, for making custom operations with selected files:

#!/bin/bash

while [ $# -gt 0 ]; do
    file=$1
    #doing smf with selected file
    shift
done

Аlso, I know about ability launch Blender in cmd, with custom python scripts:

blender -b blendfile.blend -P script.py -x 1 -F PNG -f 1

And I whant to take a value file and transfer it into python script to use it in script.py:

#!/bin/bash

while [ $# -gt 0 ]; do
    file=$1
    blender -b blendfile.blend -P script.py//+put here $file// -x 1 -F PNG -f 1     
    shift
done

how can I do this?

About this answer: Note, python script launches in blender, not in bash shell

Community
  • 1
  • 1
Crantisz
  • 227
  • 3
  • 13
  • Are you trying to say that `blender -b blendfile.blend -P script.py "$1" -x 1 -F PNG -f 1` inside the loop does not do what you are asking? – tripleee Mar 16 '17 at 10:33
  • @tripleee answer from Nils Werner works. [This answer](http://stackoverflow.com/questions/10667314/python-script-with-arguments-for-command-line-blender) explanes why this simple way doesn't work – Crantisz Mar 16 '17 at 10:41

1 Answers1

1

From blender.stackexchange

Blender ignores all arguments after a --, Python doesn't. You can search for -- in Python and read all arguments after it using

import sys
argv = sys.argv
argv = argv[argv.index("--") + 1:]  # get all args after "--"

The arguments you would be passing in then look like

blender -b blendfile.blend -P script.py -x 1 -F PNG -f 1 -- $file
Community
  • 1
  • 1
Nils Werner
  • 34,832
  • 7
  • 76
  • 98