Created
April 11, 2022 23:25
-
-
Save discarn8/485ae6512a12cf2d444f0bb6d53bb0f0 to your computer and use it in GitHub Desktop.
Rename with overwrite verify
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 | |
IFS='' | |
echo -n "Enter text to rename: " | |
read -r rename | |
echo -n "Enter filetype to search (txt, jpg, pdf, etc): " | |
read ftype | |
while true; do | |
read -p "The text to rename is \""${rename}"\" and the filetype is \""${ftype}"\" - Is this correct? " yn | |
case $yn in | |
[Yy]* ) for i in *.$ftype; do | |
echo "Renaming $i"; | |
mv -i "$i" "`echo "$i" | sed \"s/$rename//g\"`"; | |
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