changing the file-name in a directory for all files matching a particular criteria

i have a directory which consist of multiple files out of which there are some files that has -e in their name.

I want to write a script that will change all those file-name to -l

example there are some files with name :

file1-e.wav
file2-e.wav
file3-english-e.wav
file-4-e.wav

expected output

file1-l.wav
file2-l.wav
file3-english-l.wav
file-4-l.wav
for f in file*-e.wav ; do mv $f ${f%-e.wav}-l.wav ; done
1 Like

Like this?

for i in *-e.wav
do
 echo mv $i ${i/%-e.wav/-l.wav}
done

Remove the echo if the mv commands look proper.

for i in $(find statement)
do
new_name=$(echo $i | sed 's/-e/-l/g')
echo "mv $i $new_name"
done

if you are getting your required result. Just remove echo.:slight_smile:

1 Like