detect unicode file names and rename them!

How to DETECT non-english characters inside file names and rename them???

Please help!

Comments

Comment viewing options

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

Try this function:

-- function to make a filename valid by replacing illegal characters with a '_'
		function MakeFileNameValid fileName = -- fname must be just filename, no path....
		(
			local illegal_characters =":/\\~!@#$%^&*()+=|'?><;[]{}\"" -- illegal characters in file name
			local res = copy fileName
 
			-- make sure the object name is legal for a filename
			local count = res.count
			for i = 1 to count do
			(
				if (findString illegal_characters res[i]) != undefined do -- replace illegal characters with _
					res[i] = "_"
			)
			--
			res
		)
artrender.info's picture

I've found smth like this for php and javascript

php

if (preg_match('/[^\x30-\x7F]/', $_POST['full_name']) > 0)
{
    $error = true;
}

x30 will exclude: !"#$%&'()*+,-./.

java

var foreignCharacters = $("#foreign_characters").val();
var rforeign = /[^\u0000-\u007f]/;
 
if (rforeign.test(foreignCharacters)) {
  alert("This is non-Latin Characters");
} else {
  alert("This is Latin Characters");    
}

how to implement these things in maxscript:

for m in getClassInstances BitmapTexture where (foreignfn m.filename == true) do
 
rename m.filename

For the other hand we have:

character.set parameter for maxscript! I'm still confused!!!

Comment viewing options

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