Silgrad Tower from the Ashes

Full Version: Batch-mode bulk NIF retexturing tool wanted
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Does anyone know a way to update 1 or 2 textures in each of 62 nifs into 3 new pairs of textures without going into each one individually in nifscope to perform 186 individual edits and gradually losing your mind..!

I'm trying to do a bulk retex on the architecture/stonewalls set for three different landscape regions. I found Texture Replacer but can't seem to make it work: it just breaks the NIFs.

Ideally, I'd like it if NifSkope had a "batch" mode, but it doesn't seem to. Has anyone come across a suitable tool?

Update:

OK, I had to put my programmer head on for this one, which is unfortunate: because its a rather mouldy old turnip now used as a candleholder in the shed.

My tool of choice, I think, is going to be niftoaster. This is a Python script supplied with the PyFFI toolset. The main reason I'm going with this is that it's current. PyFFI is actively in development on sourceforge.

However, the documentation appears to have been written exclusively by programmers and is therefore fundamentally incomprehensible to ordinary mortals. I was just about able to make enough sense of it to get it to run.

To run niftoaster, you need to have PyFFI installed, and for that you need Python 2.6. Once those are installed, and if you've selected all the defaults, then you should have the following file:
c:\Python26\Scripts\niftoaster.py
.. lots of other files and folders too, of course, but that's niftoaster.

It's a command line tool. Check all's well by opening a cmd.exe and running these commands:
C:
cd C:\Python26
python Scripts\niftoaster.py --help

you should get the output:
Usage: niftoaster.py [options] <spell1> <spell2> ... <file>|<folder>
Apply the spells <spell1>, <spell2>, and so on, on <file>, or recursively on
<folder>.

Options:

.... and lots more info.

"Spells" are programs that niftoaster will run on the files. You can get a full list with the command
python Scripts\niftoaster.py --spells

The one I'm interested in is modify_substitutetexturepath. I tried the built in help:

python Scripts\niftoaster.py --help-spell modify_substitutetexturepath

pyffi.toaster:INFO:Runs a regex replacement on texture paths.

Well, after that not-so-helpful start, I did work it out. To run niftoaster for my retex, I created a batch file in my project working folder called retex.bat containing the following:

Code:
c:
cd c:\python26
python  Scripts\niftoaster.py -a /architecture\\stonewall\\Stonewall01.dds/Elsweyr\\architecture\\stonewall\\EwMdStoneWallDesert01.dds modify_substitutetexturepath "C:\\Program Files\\Bethesda Softworks\\Oblivion\\Data\\Meshes\\Elsweyr\\Architecture\\stonewall\\desert\\mod\\"

pause
:eek: What's all that then?

The actual syntax here is,
python Scripts\niftoaster.py -a [regular expression (regex) replacement string] [spellname] [filepath]

"-a" prefixes an argument that will be passed to all the "spells"
niftoaster has a whole heap of "spells" that can be run on all the files found in [filepath]
the one I'm interested in is modify_substitutetexturepath

so for me the real fight was finding out what a regex replacement string was and how to write one to go in [regular expression (regex) replacement string]

What we've basically got in there is:
/change this/to this
all the backslashes are just doubled-up because Python likes it that way.
I suspect this is all very case sensitive.

When you run the batch file, which you can from Windows explorer if you like, it pops up a dosbox and prompts:

This script will modify your files, in particular if something goes wrong it
may destroy them. Make a backup of your files before running this script.

Are you sure that you want to proceed? [n/y]

If you didn't make a backup before this then now would be a good time!

Say "Y" and it'll churn through all the files making the change.

You can get much fancier with regular expressions, replacing just exactly those parts you need, but this is enough for me for tonight.

As intimated earlier, there's other stuff you can do with niftoaster - there's a guide to using it for Nif Optimisation on CS Wiki by Razorwing.

Hope that helps someone....
TR is the only one out there. its command line, so you have to be really, really careful. i recommend you back up the files you need and try it a couple times, its worked great for me in the past.
Thanks, LadyN, but I think the answer for me is probably niftoaster, which is supplied with PyFFI. I couldn't work out TF's quirks in an hour, so I may as well put the effort into something that appears to do so much more. I'm still bunking off work and trying to get my head around niftoaster...!

Very sound point about the backups - I do try and have at least three of everything!
huh, havent heard of niftoaster before. do post your experiences with it, i foresee quite a bit of mass retexturing in my future and it might come in handy.
LadyN, do you know of a tutorial for using TR? I too have a lot of retexturing to get through for High Rock.
not really, sorry. the readme outlines the proper code towards the bottom, just pay close attention to what youre typing and how you type it. keep backups, cause you're almost certainly going to corrupt a model or two. i kept the program in the same folder as the models i was retexturing to make the path smaller. its been a while since i've used it.
Thanks. I'll give it a go.
If you're not in a massive hurry, then wait until I've had a look at niftoaster. I think my problems with TR may have stemmed from wanting to rename and relocate textures from one deep hierarchy to another, and I couldn't work out how to get the paths right.
TR is an old program, written for TES3 and last updated in 2006
niftoaster's part of PyFFI which is bang up to date and actively supported on sourceforge.
I know which I'd rather use if I can get it to work....!

There's an outline tutorial for the "Optimise spell" on CS Wiki by our very own Razorwing - it doesn't cover retex, but I know that's another of the available spells. I'll post more info here when I'm done. Should be soon: I want this fixed!
Thanks. I think I'll hold off for the moment and wait and see how your experiments turn out then...
Well, it works. OP edited with a rough-and-ready "how to"
Pages: 1 2