Skip to content

Instantly share code, notes, and snippets.

@discarn8
Created April 12, 2022 00:14
Show Gist options
  • Save discarn8/ff1a573b007636dc14c93a85c952036d to your computer and use it in GitHub Desktop.
Save discarn8/ff1a573b007636dc14c93a85c952036d to your computer and use it in GitHub Desktop.
RenameCharacter
#!/bin/bash
IFS=''
echo -n "Enter character to remove: "
read -r rename
while true; do
read -p "The character to remove is \""${rename}"\" - Is this correct? " yn
case $yn in
[Yy]* ) for i in *; do
if [[ "$i" == *"_"* ]];then
echo "Found a file....";
sleep 2;
echo "Renaming $i";
mv -i "$i" "`echo "$i" | sed \"s/$rename/ /g\"`";
#mv "$i" "`echo $i | sed "s/_/ /g"`";
fi;
done;
break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo "Renaming done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment