Transliteration is possible?

Hello. i found only a topic with dynamic renamer that was 9 years ago. may be there is a new and simple method to transliterate names like in totalcommander(sorry, never use it, but found this possibility in it via search) Dopus's find&replace doesn't accept () | or *

Using a rename script would be best for that, if you mean mapping one character set to another. It's not something you can do with a single regex, wildcard, or search & replace operation, but it'd be easy to do with a little script that loops through each character and replaces it according to whichever rules you want.

i just found

function translit_file($filename)
{
	$converter = array(
		'а' => 'a',    'б' => 'b',    'в' => 'v',    'г' => 'g',    'д' => 'd',
		'е' => 'e',    'ё' => 'e',    'ж' => 'zh',   'з' => 'z',    'и' => 'i',
		'й' => 'y',    'к' => 'k',    'л' => 'l',    'м' => 'm',    'н' => 'n',
		'о' => 'o',    'п' => 'p',    'р' => 'r',    'с' => 's',    'т' => 't',
		'у' => 'u',    'ф' => 'f',    'х' => 'h',    'ц' => 'c',    'ч' => 'ch',
		'ш' => 'sh',   'щ' => 'sch',  'ь' => '',     'ы' => 'y',    'ъ' => '',
		'э' => 'e',    'ю' => 'yu',   'я' => 'ya',
 
		'А' => 'A',    'Б' => 'B',    'В' => 'V',    'Г' => 'G',    'Д' => 'D',
		'Е' => 'E',    'Ё' => 'E',    'Ж' => 'Zh',   'З' => 'Z',    'И' => 'I',
		'Й' => 'Y',    'К' => 'K',    'Л' => 'L',    'М' => 'M',    'Н' => 'N',
		'О' => 'O',    'П' => 'P',    'Р' => 'R',    'С' => 'S',    'Т' => 'T',
		'У' => 'U',    'Ф' => 'F',    'Х' => 'H',    'Ц' => 'C',    'Ч' => 'Ch',
		'Ш' => 'Sh',   'Щ' => 'Sch',  'Ь' => '',     'Ы' => 'Y',    'Ъ' => '',
		'Э' => 'E',    'Ю' => 'Yu',   'Я' => 'Ya',
	);
	
	$new = '';
	
	$file = pathinfo(trim($filename));
	if (!empty($file['dirname']) && @$file['dirname'] != '.') {
		$new .= rtrim($file['dirname'], '/') . '/';
	}
 
	if (!empty($file['filename'])) {
		$file['filename'] = str_replace(array(' ', ','), '-', $file['filename']);
		$file['filename'] = strtr($file['filename'], $converter);
		$file['filename'] = mb_ereg_replace('[-]+', '-', $file['filename']);
		$file['filename'] = trim($file['filename'], '-');					
		$new .= $file['filename'];
	}
 
	if (!empty($file['extension'])) {
		$new .= '.' . $file['extension'];
	}
	
	return $new;
}
 
echo translit_file('/upload/Пример файла.jpg');

or this

function translit(word){
   var answer = '';
   var converter = {
   	'а': 'a',    'б': 'b',    'в': 'v',    'г': 'g',    'д': 'd',
   	'е': 'e',    'ё': 'e',    'ж': 'zh',   'з': 'z',    'и': 'i',
   	'й': 'y',    'к': 'k',    'л': 'l',    'м': 'm',    'н': 'n',
   	'о': 'o',    'п': 'p',    'р': 'r',    'с': 's',    'т': 't',
   	'у': 'u',    'ф': 'f',    'х': 'h',    'ц': 'c',    'ч': 'ch',
   	'ш': 'sh',   'щ': 'sch',  'ь': '',     'ы': 'y',    'ъ': '',
   	'э': 'e',    'ю': 'yu',   'я': 'ya',

   	'А': 'A',    'Б': 'B',    'В': 'V',    'Г': 'G',    'Д': 'D',
   	'Е': 'E',    'Ё': 'E',    'Ж': 'Zh',   'З': 'Z',    'И': 'I',
   	'Й': 'Y',    'К': 'K',    'Л': 'L',    'М': 'M',    'Н': 'N',
   	'О': 'O',    'П': 'P',    'Р': 'R',    'С': 'S',    'Т': 'T',
   	'У': 'U',    'Ф': 'F',    'Х': 'H',    'Ц': 'C',    'Ч': 'Ch',
   	'Ш': 'Sh',   'Щ': 'Sch',  'Ь': '',     'Ы': 'Y',    'Ъ': '',
   	'Э': 'E',    'Ю': 'Yu',   'Я': 'Ya'
   };

   for (var i = 0; i < word.length; ++i ) {
   	if (converter[word[i]] == undefined){
   		answer += word[i];
   	} else {
   		answer += converter[word[i]];
   	}
   }

   return answer;
}

but it doesn't work with rename script and i'm not familiar to edit it properly. is anybody can?

Set the language to JScript and add this to the top of your second script:

function OnGetNewName(getNewNameData)
{
	return translit(getNewNameData.newname);
}

1 Like