I
I
ILoveYAnny2016-06-12 14:57:41
linux
ILoveYAnny, 2016-06-12 14:57:41

How to change the file name to transliteration in Ubuntu and put a flag before each changed character?

Hello, there is such a task. There is a folder with mp3 files. I need to leave the Latin alphabet unchanged, and translate the Cyrillic alphabet into transliteration and put a flag in front of each changed character.
That is, from "Track - Name" get "Track - [r]i[r]m[r]y[r]a"
What is it for - there is a system that cannot work with Cyrillic, but I need to show Russian to the user names. I came up with the idea to translate only Russian characters into transliteration on the server, somehow mark them. And on the client, already in JS, parse and replace in the same alphabet with Russian.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
abcd0x00, 2016-06-12
@ILoveYAnny

[[email protected] ~]$ \
> func ()
> {
>     read s
>     for ((i = 0; i < ${#s}; i++)); do
>         c=${s:$i:1}
>         case $c in
>             "а") oc="a";;
>             "б") oc="b";;
>             "в") oc="v";;
>             "г") oc="g";;
>             "и") oc="i";;
>             "й") oc="j";;
>             "к") oc="k";;
>             "л") oc="l";;
>             "н") oc="n";;
>             "о") oc="o";;
>             "с") oc="s";;
>             "я") oc="ya";;
>               *) oc="$c";;
>         esac    
>         echo -n "$oc"
>     done
>     echo
> }
[[email protected] ~]$ 
[[email protected] ~]$ echo "яблонский головоног" | func
yablonskij golovonog
[[email protected] ~]$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question