Last active
July 11, 2023 08:58
-
-
Save a-vasyliev/009cb30a7bd99a61d1bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Перекодирует рекурсивно в текущем каталоге имена | |
# файлов и каталогов в транслит. | |
# | |
# Источник: http://www.ubuntu.sumy.ua/2011/03/translit.html | |
shopt -s nullglob | |
for NAME in * ; do | |
TRS=`echo $NAME | sed "y/абвгдезийклмнопрстуфхцы/abvgdezijklmnoprstufxcy/"` | |
TRS=`echo $TRS | sed "y/АБВГДЕЗИЙКЛМНОПРСТУФХЦЫ/ABVGDEZIJKLMNOPRSTUFXCY/"` | |
TRS=${TRS//ч/ch}; | |
TRS=${TRS//Ч/CH} TRS=${TRS//ш/sh}; | |
TRS=${TRS//Ш/SH} TRS=${TRS//ё/jo}; | |
TRS=${TRS//Ё/JO} TRS=${TRS//ж/zh}; | |
TRS=${TRS//Ж/ZH} TRS=${TRS//щ/sh\'}; | |
TRS=${TRS///SH\'} TRS=${TRS//э/je}; | |
TRS=${TRS//Э/JE} TRS=${TRS//ю/ju}; | |
TRS=${TRS//Ю/JU} TRS=${TRS//я/ja}; | |
TRS=${TRS//Я/JA} TRS=${TRS//ъ/\`}; | |
TRS=${TRS//ъ\`} TRS=${TRS//ь/\'}; | |
TRS=${TRS//Ь/\'} | |
if [[ `file -b "$NAME"` == directory ]]; then | |
mv -v "$NAME" "$TRS" | |
cd "$TRS" | |
"$0" | |
cd .. | |
else | |
mv -v "$NAME" "$TRS" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello. And is it works with sub folders for translit?
Thanks.