Created
April 3, 2015 09:56
-
-
Save gaintsev/bd864ad3e123bfdc0ca7 to your computer and use it in GitHub Desktop.
Transliteration of the Russian filenames
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 | |
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