Rename texture name

The scene have many textures, but the texture name is not correct. I want to rename the textures, and the link of texture should be keep!

I'm sorry for my bad english,I wish you can understand it.

Can someone help me? So thanks!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
3dwannab's picture

Corona Bitmap Support

--Script to rename paths of bitmap textures in a scene.
try(destroyDialog ro_bmRename)catch()
rollout ro_bmRename "Single edit Bitmap filepaths or do a search & replace on all (case insensitive)" width:906 height:495
(
	local arrBMs = #()
	local arrPaths = #()
	combobox cbx_bm "Bitmap Filepaths" pos:[6,5] width:890 height:31
	button btn_get "Get Bitmaps in Scene" pos:[5,449] width:124 height:40
	checkbutton ckb_edit "Enable Edit" pos:[134,449] width:140 height:40
	edittext edt_s "Search for:" pos:[323,450] width:439 height:16 enabled:false
	edittext edt_r "Replace with: " pos:[323,472] width:439 height:16 enabled:false
	button btn_rep "Do for All" pos:[769,449] width:132 height:40 enabled:false
	button btn_swap "Swap" pos:[279,449] width:40 height:40
 
	fn update_list=
	(
		arrBMs = #()
		arrPaths = #()
		arrCoronaBMs = getClassInstances coronaBitmap
		for o in arrCoronaBMs do append arrPaths o.filename
		arrBMs = getClassInstances bitmapTexture
		for o in arrBMs do append arrPaths arrBMs[i].filename
		cbx_bm.items = arrPaths
	)--end fn
 
	on cbx_bm entered txt do
	(
		if ckb_edit.checked do
		(
			arrBMs[cbx_bm.selection].filename = txt
			update_list()
		)--end if
	)--end on
	on btn_get pressed do
	(
		update_list()
	)--end on
	on ckb_edit changed state do
	(
		if state then
		(
			edt_s.enabled = true
			edt_r.enabled = true
			btn_rep.enabled = true
		)--end if
		else
		(
			edt_s.enabled = false
			edt_r.enabled = false
			btn_rep.enabled = false
		)--end else
	)--end
	on btn_swap pressed do
	(
		temp = edt_s.text
		edt_s.text = edt_r.text
		edt_r.text = temp
	)--end on
	on btn_rep pressed do
	(
		local searchFor = edt_s.text
		local replaceWith = edt_r.text
		if searchFor != "" AND replaceWith != "" then
		(
			--loop through object names:
			for i=1 to arrBMs.count do
			(
				local startIndex = findString arrBMs[i].fileName searchFor -- returns the starting index of the found string
 
				if startindex != undefined do
				(
					-- replace the string at "startIndex" with length of "searchFor.count" with "replaceWith" 
					arrBMs[i].fileName = (replace arrBMs[i].fileName startIndex searchFor.count replaceWith)
				)--end if
			)--end for
			update_list()
		)--end if
		else displayTempPrompt ">>>>>> Fill in what to search for and what to replace with! <<<<<<<" 5000
	)--end on
)
createDialog ro_bmRename[\code]
Kudla's picture

Hi thats excatlu what Im

Hi thats excatlu what Im looking for but dosnt work.....it says

-- Syntax error: at bad, expected
-- In line: createDialog ro_bmRename[\c

Can I use it for 3dsmax 2016 and corona 1.5

thx for hrlp

3dwannab's picture

Ill formatting of the post

Remove

[\code]

from the end of the code posted above.

Yes. It should a straight forward script there's little that can go wrong. Credit to the OP. I just made that edit for Corona.

crystal3d's picture

okay , what he wants is...

actually what i want too...
is

the script to rename all bitmaps renamed to "scene name"+ extension.
i.e.
pine_tree.max has some mesh and two textures.
leaf.bmp
leaf2.bmp

he wants a script to do some actions so the result will become:

pine_tree.max
pine_tree.bmp
pine_tree2.bmp.

and materials target the new bitmap names...so they wont report as missing.

Anubis's picture

rename w/o relink, right?

I re-read 2-3 times the original question: "I want to rename the textures, and the link of texture should be keep!" and looks like all replies below are about Relinking texture #FileNames.
--Here is 2 staffs:

<TextureMap>.name
assignNewName <TextureMap>

And as you say "the texture name is not correct", then give more details about.

my recent MAXScripts RSS (archive here)

crystal3d's picture

good subject, you want to turn an untidy scene into a tidy scene

like evermotion's scenes...
dont have a solution for you however...

br0t's picture

mhm maybe tryout "Set Bitmap

mhm maybe tryout "Set Bitmap Parameters" here: http://www.oferz.com/maxscripts.php
It has an option to do a Search&Replace on bitmap filenames

Never get low & slow & out of ideas

SmallGhost's picture

I have try it,but the file

I have try it,but the file name is not change, how to set it?

br0t's picture

Dont really know if this is

Dont really know if this is what you want but maybe it helps:

--Script to rename paths of bitmap textures in a scene.
try(destroyDialog ro_bmRename)catch()
rollout ro_bmRename "Single edit Bitmap filepaths or do a search & replace on all (case insensitive)" width:906 height:495
(
	local arrBMs = #()
	local arrPaths = #()
	combobox cbx_bm "Bitmap Filepaths" pos:[6,5] width:890 height:31
	button btn_get "Get Bitmaps in Scene" pos:[5,449] width:124 height:40
	checkbutton ckb_edit "Enable Edit" pos:[134,449] width:140 height:40
	edittext edt_s "Search for:" pos:[323,450] width:439 height:16 enabled:false
	edittext edt_r "Replace with: " pos:[323,472] width:439 height:16 enabled:false
	button btn_rep "Do for All" pos:[769,449] width:132 height:40 enabled:false
	button btn_swap "Swap" pos:[279,449] width:40 height:40
 
	fn update_list=
	(
		arrBMs = #()
		arrPaths = #()
		arrBMs = getClassInstances bitmapTexture
		for i=1 to arrBMs.count do
			append arrPaths arrBMs[i].filename
		cbx_bm.items = arrPaths
	)--end fn
 
	on cbx_bm entered txt do
	(
		if ckb_edit.checked do
		(
			arrBMs[cbx_bm.selection].filename = txt
			update_list()
		)--end if
	)--end on
	on btn_get pressed do
	(
		update_list()
	)--end on
	on ckb_edit changed state do
	(
		if state then
		(
			edt_s.enabled = true
			edt_r.enabled = true
			btn_rep.enabled = true
		)--end if
		else
		(
			edt_s.enabled = false
			edt_r.enabled = false
			btn_rep.enabled = false
		)--end else
	)--end
	on btn_swap pressed do
	(
		temp = edt_s.text
		edt_s.text = edt_r.text
		edt_r.text = temp
	)--end on
	on btn_rep pressed do
	(
		local searchFor = edt_s.text
		local replaceWith = edt_r.text
		if searchFor != "" AND replaceWith != "" then
		(
			--loop through object names:
			for i=1 to arrBMs.count do
			(
				local startIndex = findString arrBMs[i].fileName searchFor -- returns the starting index of the found string
 
				if startindex != undefined do
				(
					-- replace the string at "startIndex" with length of "searchFor.count" with "replaceWith" 
					arrBMs[i].fileName = (replace arrBMs[i].fileName startIndex searchFor.count replaceWith)
				)--end if
			)--end for
			update_list()
		)--end if
		else displayTempPrompt ">>>>>> Fill in what to search for and what to replace with! <<<<<<<" 5000
	)--end on
)
createDialog ro_bmRename

To see bitmap names, press the "Get.." Button. To edit them, enabled the checkbox. You can then select single bitmap filepaths in the list and change them on top. The changes will be accepted when you leave the edit field with your mouse.
You can also do a search and replace on all paths, e.t. to change "C:\" to "D:\"
or "silly.jpg" to "dummy.tif"
This is case insensitive, which might not be so good.
Be careful with it, better save to a new scene first before you accidently kill any paths.
Cheers

Never get low & slow & out of ideas

aj2jjworld's picture

Nice Script

Hey, i use this script. and it really work for me. script change all jpg name according to me. but in max only. but its fine and i change name with advance rename. ALL OVER VERY GOOD SCRIPT. Save lots of time.

Ajs

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.