[Closed] How to change file path on .mat using script?
Hi,
I have a bunch of .mat (materials library) files. Since, I move (eehm… reorganize)
the harddrive, I decided to move all the bitmaps file to different directory.
Now, how can I change all the path assignment inside a .mat file in one go,
instead of opening each file in max and setting the bitmaps all over again
to different directory one by one… manually?
This kind of thing should be easy to with script right? Could be
just a one liner.
Thanks in advance,
Regards,
i tried looking this up in the help file… but failed to find an appropriate function in reading/modifying .MAT files directly… i think sticking to the bitmap/photometric file path editor is your best choice…
although it is possible to write a simpler version of the editor, which would just let you change all the filepath of each bitmap in the scene to a single target directory for each maxfile… (if i hav time, i’ll try to write this for you…)
Thank you galagast
But that wouldn’t change the .mat file and save the new
bitmap file path. would it?
Ok. I thought this would be easy, now it’s challenging.
Thanks
This is really not necessary – Max can handle this automatically!
Max works like this: When a material with a bitmap map is loaded, the absolute path is tried first. If the bitmap file cannot be found at the path saved with the material, the location the MAX file was loaded from is being checked. If there is no bitmap with that name at the specified place, the Custom Map Path definitions are being scanned one by one. If no bitmap can be found, the missing bitmap dialog will be issued.
So, if all your bitmaps are under a new path, the only thing you have to do is define that path in your Map Paths list. Max will not find the bitmaps at the original location, so it will be forced to use the Map Paths instead and will find the correct files at the new location…
Example:
*The default MatLib contains a couple of background JPGs like Mountain etc. which are under Maps/Backgrounds.
*Close Max, rename the folder Maps to Maps0.
*Start Max – if you open the Material Editor and open the Library, the Maps will be missing (no error messages, just the samples will be black).
*Go to Customize>Configure Paths>External Files and add the path Maps0/Backgrounds to the list of paths.
*Open the Material Editor again and look at the MatLib – the background images will be there. If you would drag one of them to a sample slot, you will notice that the file name is missing the file path, it features just the base file name and extension.
*Close Max, restart.
*Repeat the previous step – drag a Background bitmap to a slot and look at the file name – it will have the NEW path Maps0/Backgrounds/ assigned automatically!!!
Hope this helps.
Cheers,
Bobo
wow… from the master himself.
Thank you Bobo, I did not know that.
Best regards to you