mirror of https://github.com/tLDP/LDP
32 lines
564 B
Bash
32 lines
564 B
Bash
#!/bin/bash
|
|
|
|
# rfe
|
|
# ---
|
|
|
|
# Renaming file extensions.
|
|
#
|
|
# rfe old_extension new_extension
|
|
#
|
|
# Example:
|
|
# To rename all *.gif files in working directory to *.jpg,
|
|
# rfe gif jpg
|
|
|
|
ARGS=2
|
|
E_BADARGS=65
|
|
|
|
if [ $# -ne "$ARGS" ]
|
|
then
|
|
echo "Usage: `basename $0` old_file_suffix new_file_suffix"
|
|
exit $E_BADARGS
|
|
fi
|
|
|
|
for filename in *.$1
|
|
# Traverse list of files ending with 1st argument.
|
|
do
|
|
mv $filename ${filename%$1}$2
|
|
# Strip off part of filename matching 1st argument,
|
|
#+ then append 2nd argument.
|
|
done
|
|
|
|
exit 0
|