Relocate Textures Window
by M. Borghi

The purpose of this MEL script is to help users manage texture file names and paths. This will fix texture paths coming from other users or change all the filenames from absolute to relative.

Usage:
The window has three main areas: the General Options section which lets you set all the options for the command, Scene Info section (collapsed by default) gives you some information about your scene, and the Preview section which is a preview window and is useful to check  the result before you hit the Apply button.

GENERAL OPTIONS SECTION

This area includes the following options:

SCENE INFO SECTION

This area includes information about the current scene, and is collapsed by default. To expand this window, click on the small triangle next to Scene info. The information available is:

PREVIEW SECTION

This grey section at the bottom is a preview.  When the tool is first started, it lists all the filenames found in the current scene's file nodes. The list, updates automatically as soon as you change some of the options, reporting the changes to the paths. When the list is not updated automatically, you can refresh the window contents by pushing the Preview button.  To go back to the current scene's original paths press the Reset button.

Every "empty" file node in the scene, (a texture file with an empty "Image name" field )  appears in the list as  <empty node - IGNORED - >

USING THE SCRIPT

This example will show you how to take advantage of the Relocate to option.

The Relocate to option, affects the "sourceimages" part of a filename. A filename, is generally made of three elements.  The following is a typical filename:

the first part is the absolute current project's path which is: The second part is the directory included in your project intended as your bitmaps storage directory.  In the example it's sourceimages/ but it can be different or include additional subdirectories. This part of the name appears in both Absolute and Relative mode and is affected by the Relocate to options.

The third and last part of the name is the filename.

When Relocate to is set to Automatic, the current sourceimages directory is taken as the "second part" of the new pathname and any existing subdirectory in the original file name is ignored.

For example, if you have two textures with the paths:

Automatic is handy when you have a standard directories structure and you only want to change paths from relative to absolute or vice versa.

If you have subdirectories and all the textures in your scene refer to a common sourceimages directory like:

...projects/mytexturesdir/characters/dog/tail.iff
...projects/mytexturesdir/characters/dog/nose.iff
...projects/mytexturesdir/characters/man/dress/tie.iff
...projects/mytexturesdir/characters/man/body/head/hires/eye.iff

You can turn on the Trace original path checkbox specifying mytexturesdir in the text field and the subdirectories structure below the mytexturesdir directory will be preserved.

NOTE: Be sure all textures have mytextures in the path or you may get undesirable results. In this case a dialog box will warn you.

TIP: Leaving the textfield empty, will work if you want to fix paths missing their "sourceimages" directory like:

The This directory option, gives you the ability to explicitly specify one of your sourceimages directories as the relocation directory. This is useful if you want to change all the pathnames to a particular existing directory.

NOTE: The script, scans your project directory structure to automatically prompt the available directories. If you haven't set a file texture location in your project, the popup menu can contain incorrect directory names.

Tip: If used in conjunction with the Change Selected nodes, allows you to manually relocate groups of nodes.