Last active
August 30, 2021 15:38
-
-
Save idkjs/dadc6eb017a59782a2310f0a7cd4dfba to your computer and use it in GitHub Desktop.
rename extensions
This file contains hidden or 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 | |
echo "Enter the target directory " | |
read -r target_dir | |
cd "$target_dir" || exit | |
echo "Enter the file extension to search without a dot" | |
read -r old_ext | |
echo "Enter the new file extension to rename to without a dot" | |
read -r new_ext | |
echo "$target_dir, $old_ext, $new_ext" | |
for file in *.$old_ext | |
do | |
mv -v "$file" "${file%.$old_ext}.$new_ext" | |
done; |
This file contains hidden or 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
https://linuxhint.com/change-file-extension-multiple-files-bash/ | |
Or | |
```sh | |
find . -iname '*.res' | sed 'p;s/\.res/\.re/' | xargs -n2 mv | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment