.dotfiles/configs/zsh/functions/mv-safe.zsh

12 lines
419 B
Bash
Raw Normal View History

2022-04-08 17:37:26 +02:00
function mv-safe(){
for OLD_NAME in "$@"
do
NEW_NAME="$(echo $OLD_NAME | sed -e 'y/āáǎàēéěèīíǐìōóǒòūúǔùǖǘǚǜĀÁǍÀĒÉĚÈĪÍǏÌŌÓǑÒŪÚǓÙǕǗǙǛ/aaaaeeeeiiiioooouuuuüüüüAAAAEEEEIIIIOOOOUUUUÜÜÜÜ/' | sed -e 's/[^A-Za-z0-9._-]/_/g')"
if [ $OLD_NAME != $NEW_NAME ]; then
mv $OLD_NAME $NEW_NAME;
else
echo "No need to rename $OLD_NAME";
fi
done
}