Remapping the references before loading the file

My problem is the following: There are huge amount of maya scenes with referenced characters, but the folder structure has been changed. I haven't found any useful method to automatically change the reference paths in the scenes. if i open them the reference browser will show up, but i dont want it, because i have to run some automatized procedures on them. So is there any way in mel or python to remap broken reference paths automatically? thanks for the help.

Yes, its called: dirmap.

See the mel or python reference (yoru choice) of maya for examples of use and documentation.

Thanks for the idea, but i have 100+ reference files each in it's own directory, and the folder structure is quite complicated, i think the dirmap command is mainly useful to map 1 or few dirs, but tell me if i'm wrong.
I started to solve the problem with reading the reference path: file -q -reference $FileToOpen. but is can't write it this way.

useful to map 1 or few dirs

usefull irrespecively how may dirs you map*. (i dont see any reason why mapping a 10,000 driectories would be any harder or less useful.)

You dont actually have to map the full path you can just map a part of it. (yes yes if you read the docs you might come to different conclusin but maya actually maps the subdirectories aswell)

and the folder structure is quite complicated

Well had you actually done it the way maya tells you to do it youd have no problems right now. Maya doesnt actually acre how complicated your directory tree is. All maya cares for is that you build a sane project heiarachy so maya knows what the hell your hierarchy is.

I mean had you said thet the base of your project was the base of your project maya would know to repoint the data. So that everything irrespectively of HOW many drectories would be under a abstract base folder.

eg:

cmds.dirmap( en=True )
cmds.dirmap( m=('C:/usr/maya/', '/share/store/') )
cmds.dirmap( cd='C:/usr/maya/files/' )
# Result: /share/store/files/ #

So maya now consiiders the entire directory moved including all paths relative to that please note even:

cmds.dirmap( cd='C:/usr/maya/../extraResources/' )
# Result: /share/store/../extraResources/ #

is perfectly valid so even relative paths get automatically remapped to the new directory location as long as the genral logic didnt change

so unless you guys were actually doing a permanent suicide and actually manually just replace filenames at random then it shoulddnt really matter where you mpved the files. If on the otherhand you renamed each and every directory and file in question. Then i really hope for yoursake somebody has a logfile as to their new locations.

Offourse if you changed all directoris like following:

c:/project/myNewProject/ -> c:/project/myNewProject/backup
c:/resources/resource1/ -> c:/project/myNewProject/backup

Then yeah you have a problem. Tough not really you can just load the files and loop tough every filename and replace them tough this is a bit tedious but feasible and it does work.

  • my user setup maps 60 directories automatically to meet my config difference versus the old structure.

There's another problem:) the directory hiererchy has been completely changed. Like in the old system there was only one directory for all character (..../Characters/Goblin/3D/setup/lib/Goblin_setup.mb, ..../Characters/Ship/3D/setup/lib/Ship_setup.mb), and the new one has been separated to categories plus the inner-character structure has been changed too (..../Creatures/Goblin/setup/Goblin_setup.mb,  ..../Props/Ship/setup/Ship_setup.mb).
Thats why i thougt dirmap wouldn't work, because from one structure has been more, but i hope i'm wrong, because i really don't want to manually load all the files:D

OK yes your going to have to open all files and loop tough all file references. But thenagain when you made the change you had to loop over the files to rename the folders too. Reuse that script.

But thenagain you should have tought about that when you changed the file structure,  done all maya related changes form from within maya. But yes i dont think its your fault, as most likely you are the mopping crew.