ScriptSpot

Forum topic · Scripts Wanted

Batch renamer

By arch3d · 2016-10-13

Description

Hi all,
I am looking for simillar script to this one
http://www.scriptspot.com/3ds-max/scripts/rh-map-node-renamer

this one is not available any more:(

I would like to do some batch rename:
- script checks if there is a bitmap texture assigned to "diffuse", "specular", "opacity" and
"bump".
- renames the textures asigned using the pattern "NameOfTheObject_NameOfSlot.*"
ex.box_diffuse.jpg

Finally
- renames bitmap node same as texure name without extension ex. sample_difuse.jpg ---> bitmap slot sample_diffuse

I hope i explained it correct.

Thanks for help
Cheers

Comments (3)

Using Object Name not Material Name.

asymptote · 2017-12-27

I just tried this in Max 2016, it renames the "on disk" texture files to the object name not the material name.

Is it supposed to do this or an I doing something wrong?

I desperately need a batch script that renames the on disk texture files to the material name in the material editor and updates the paths.

Can anyone help?

tia.

Works!

arch3d · 2016-10-17

Thank you very much!!!

`

pixamoon · 2016-10-15

oki, here it is, I add there make unique names because there might be for eg multiple diffuse maps in for one object (MultiSubMateiral or blend etc)

But be very careful with using it - it changes files on HDD. That's why I would recommend to use method - COPY files only to new location



method = #copy  

-- I recomend to COPY files to new location with new names
-- but if you realy want to rename
-- than change method to #rename

NewFolder = "C:\\NewFolderLocation\\"

if not doesFileExist NewFolder do makedir NewFolder

UniqueMatArr = #()
UniqueBitmapTArr = #()

fn FnFindMaps m objName = 
	if m !=undefined then 
	(
		for i = 1 to getNumSubTexmaps m do (
			if (tm = getSubTexmap m i) != undefined do 
				if classof tm == BitmapTexture and finditem UniqueBitmapTArr tm == 0 then 
				(
					append UniqueBitmapTArr tm
					if doesFileExist tm.filename do (
						newBitmapName = uniquename (objName + "_" + getSubTexmapSlotName m i + "_")
						tm.name =  newBitmapName
						case method of (
							#copy : (
								newFileName = NewFolder + "\\" + newBitmapName + getfilenametype tm.filename
								copyfile tm.filename newFileName
								tm.filename = newFileName
							)
							#rename : (
								newFileName = getfilenamepath tm.filename + "\\" + newBitmapName + getfilenametype tm.filename
								renamefile tm.filename newFileName
								tm.filename = newFileName
							)
						)
					)
				)
			FnFindMaps (getSubTexmap m i) objName
		)
	)

fn FnFindMaterials m objName = 
	if m != undefined and findItem UniqueMatArr m == 0 do 
	( 
		append UniqueMatArr m
		if Superclassof m == Material then 
			for i = 1 to getNumSubMtls m do (
				FnFindMaterials (getSubMtl m i) objName
			)
			
		FnFindMaps m objName
	)
	
for o in objects do FnFindMaterials o.material o.name
	

Best,
Pixamoon