I would like to change a file extension from *.txt
to *.text
. I tried using the basename
command, but I'm having trouble on changing more than one file.
Here's my code:
files=`ls -1 *.txt`
for x in $files
do
mv $x "`basename $files .txt`.text"
done
I'm getting this error:
basename: too many arguments Try basename --help' for more information
find . -iname '*.txt' -exec bash -c 'mv -- "$1" "${1%.txt}.text"' bash {} \;
mv $x "`basename $x .txt`.text"
.