So say I have a bunch of max scene files. Like most scene files, these files have materials that point to a specific filename located in a specific folder. Redirecting the path, I know how to do... so long as the material is named the same... My problem is, the texture file names are using (-) dashes in it's naming convention and we want to change them all to (_) an underscore, just like using a batch file renamer prog.
My question to you is, is there a feature, plugin, etc. that will enable someone to Find "This" in a Path/Filename and replace it with "That" for a handful of Max files?
Thanks good-look'n.
Replies
I'm not sure if you can script it or not...
The idea is to do this to like 10 max files, all in one mighty blow.
Find "-" and Replace "_" for all max files in a directory or however you'd delegate that.
Not just one at a time.
You could probably adapt this to do what you want.
Could just use something like TextPad, and do a batch find/replace in the max files just by opening them in there.
I think it'd be pretty easy to write a maxscript that goes through all the materials in each scene, checks all their maps for bitmap paths, and replaces the "-" with "_".
Can't edit a binary file in a text editor (unfortunately).
Oh, also KP, I did a search for batch on scriptspot, there were a couple other scripts in the list that might be closer to what you want. Good luck man.
Oh also there's a great bitmap-name find/replace script from Blur called Change Bitmaps that does a quick job, quicker & more automated than the Asset Tracker or the Bitmap Paths util.
http://www.neilblevins.com/blurscripts/blurscripts.htm
Well that'd be a no-brainer. He did say that he was looking to rename a specific file being referenced. If he had is search and replace the filename as a whole, he wouldn't have to worry about any miscellaneous replacements throughout the files.
Replace: file-name.dds
Replace with: file_name.dds
Can't get messed up there.
Plus, I dunno how many text editors have batch file operations without having to open all the files at once...
Either way, I'm writing a slightly better one now with a frontend dialog window, better error handling, and better replace options for Max 2008 - still working on the one for Max versions earlier than 2008 because they added a "replace string" command in 2008 which makes this sort of thing really easy.
Click here to download it.
Overview
- Can replace any string (case-sensitive) in a path, filename or extension.
- Works on every bitmap texture found in a scene (regardless of format).
- Can convert paths to upper or lower case if necessary.
- Tested on Max 8 and Max 2008.
- Runs as a MacroScript - you will find it in the Customize menu under "MoP's Tools" category, I recommend you drag it to a toolbar.
Some suggested uses
- Change a whole set of scenes which point bitmap paths to a certain folder, to point at a different folder.
- Change a whole set of scenes to point at .tga format instead of .psd
- Make all your texture paths lower-case for compatibility.
I ended up doing this because I figured I might find it useful too at some point. While I'm aware that there are probably scripts like this out already (several links in this thread seem to indicate as such), I wanted to learn a bit more scripting.
Let me know if you come across any bugs. I tried to be fairly thorough, I didn't manage to break it yet... but you guys are all monsters, I'm sure it'll be torn apart in no time
I also had to write custom functions for upper-case, lower-case conversion, and find/replace within a string ... Max 2008 has all of these built in as easy maxscript commands, but Max 9 and earlier don't, and I wanted at least a bit of backwards compatibility. If you're using Max 2008, it will use the Max 2008 algorithms, since I guess it might be a bit faster than my method.
Disclaimer
I strongly advise you back up any files or copy them to a new folder before running this script. I am not responsible for any problems caused or data lost due to running this script on your Max files.
Cheers,
-MoP
Disclaimer: my solicitors at Dewey, Cheetham, & Howe will be contacting you shortly.
Thanks MoP!
I copied 6 work max files into a new folder: C:\Rename
The real names of these files have been changed to protect their real identity:
1.A_B_Head01.max
2.A_B_Head02.max
3.A_C_Hair01.max
4.A_C_Hair02.max
5.A_C_Head02.max
6.A_C_Head03.max
*For every attempt below, my Replace entry was always: "_" with "-" using only the "Bitmap file name" process.
Windows XP Professional SP2, Using Max 9, my first attempt, I ran the script from within A_B_Head01.max, it really disliked having the files set to Read-Only.
Running the script, prompts an obvious texture path change made visible in the viewport. Closing Max will prompt a save. Clicking yes prompts the following IO Error:
"The file <C:\Rename\A_B_Head01.max> is read-only. It will not be overwritten. Please use Save As to select new file name."
That's no prob, and an acceptable exception I'd think.
So restarting, my second attempt, I deleted and recopied the same 6 max files, disabled the Read-Only file attribute, and ran the script again within A_B_Head01.max and it kinda worked! It had only affected 1 of the 6 max files in the directory (The first, in alphabetical order). And, it only renamed the first, top right, Material Slot in the Material Editor.
My third attempt is recopying the 6 files, disabling Read-Only, but running the script from an Untitled, fresh max scene, and entering all the same parameters. I can see it attempts to open A_B_Head01.max and run the script, but crashes with "Application Error".
Same setup and result on my forth, only I attempted to run the script from "A_C_Head03.max", a file within the directory, but is not processed first. It seems it can't get past saving the first max file to continue on it's marry way.
The script crashes Max on me while using the same "Replace entries" a second time, on the same directory and files. It seems to me it dislikes having nothing to change maybe? *does not compute! -- Ack! FIZZ!*
No pressure, but your Awesomeness is now on the line! Juuust josh'n
I deleted A_B_Head01.max and it ran through the remaining 5 max files correctly, changing all Materials, and all files, just as it's intended. It so works. The script doesn't like something in A_B_Head01.max... I'll keep testing it.
I'll see if I can quickly punch in Multi/Sub material support. Shouldn't take too long.
Anything else wrong apart from that?
EDIT: Fixed to work with multi-materials too ... download from the same location in my previous post. If the "Help" panel says "v1.1" then you've got the right version
EDIT: Working like a fucking CHARM. YOU RULE!!!