# Please help?! Change Texture directories through Command Prompt with Python

**URL:** <https://blenderartists.org/t/please-help-change-texture-directories-through-command-prompt-with-python/560519>\
**Category:** Beginning Blender Code and Development\
**Created:** [December 26, 2012, 9:13am UTC](https://blenderartists.org/t/please-help-change-texture-directories-through-command-prompt-with-python/560519 "2012-12-26T09:13:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mighty\_Cow](https://blenderartists.org/user_avatar/blenderartists.org/mighty_cow/32/6786_2.png) [@Mighty\_Cow](https://blenderartists.org/u/Mighty_Cow)\
**Post date:** [December 26, 2012, 9:13am UTC](https://blenderartists.org/t/please-help-change-texture-directories-through-command-prompt-with-python/560519/1 "2012-12-26T09:13:41Z")

</div>

Hello,

I am working on an art project, and I want to get my materials to change texture directories and render when I call the python in command prompt. For example:

Blender.exe -b C:\Example.blend -P C:\NewDir.py – “C:/textures/new\_directory\_goes\_here”

From what I have learned:

import bpy  
import sys

mypath = sys.argv.index(’’)

bpy.data.images[‘example.jpg’].filepath = (mypath)  
bpy.ops.render.render(animation=True, write\_still=True)

I want to be able to specify a directory in the command prompt when I call the -P, so that mypath will change to the directory listed in the command from command prompt.

---

<div class="post-metadata">

**Author:** ![ideasman42](https://blenderartists.org/user_avatar/blenderartists.org/ideasman42/32/900508_2.png) [@ideasman42](https://blenderartists.org/u/ideasman42)\
**Post date:** [December 27, 2012, 4:00am UTC](https://blenderartists.org/t/please-help-change-texture-directories-through-command-prompt-with-python/560519/2 "2012-12-27T04:00:42Z")

</div>

See the background\_template.py from the text editor templates menu.

```auto

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

```

then do…  
mypath = argv[0]

---

<div class="post-metadata">

**Author:** ![Mighty\_Cow](https://blenderartists.org/user_avatar/blenderartists.org/mighty_cow/32/6786_2.png) [@Mighty\_Cow](https://blenderartists.org/u/Mighty_Cow)\
**Post date:** [December 27, 2012, 6:30pm UTC](https://blenderartists.org/t/please-help-change-texture-directories-through-command-prompt-with-python/560519/3 "2012-12-27T18:30:36Z")

</div>

Hy god. you are a genius. Works perfectly.  
JOY!

---

<div class="post-metadata">

**Author:** ![Mighty\_Cow](https://blenderartists.org/user_avatar/blenderartists.org/mighty_cow/32/6786_2.png) [@Mighty\_Cow](https://blenderartists.org/u/Mighty_Cow)\
**Post date:** [December 27, 2012, 6:34pm UTC](https://blenderartists.org/t/please-help-change-texture-directories-through-command-prompt-with-python/560519/4 "2012-12-27T18:34:15Z")

</div>

how do I give you stars!

---

<div class="post-metadata">

**Author:** ![jameskenrich](https://blenderartists.org/user_avatar/blenderartists.org/jameskenrich/32/24751_2.png) [@jameskenrich](https://blenderartists.org/u/jameskenrich)\
**Post date:** [January 22, 2013, 3:47am UTC](https://blenderartists.org/t/please-help-change-texture-directories-through-command-prompt-with-python/560519/5 "2013-01-22T03:47:13Z")

</div>

Wonderful information and so fun to read! Thank you. Technology helps make this an amazing world – or does it just help make the world?
