Rename multiple files in a directory using sed in Linux

Renaming multiple files

        Renaming one or couple file is easy. What if renaming has to be done to more than 50 files. That is going to take lots of time. If you want to rename files all at once in a directory then you can use following syntax.

         For example if you have a directory called /apps/newapp and there are 50 files with name summer-1001.txt  summer-1002.txt and so on and you want to rename from summer to spring then go into the directory

cd /apps/newapp

for i in *; do mv “$i” “echo $i | sed "s/summer/spring/"`" ; done

then all the filename will be changed from summer to spring

Leave a Reply