So, I have the following structure: . .. a.png b.png c.png I ran a command to resize them ls | xargs -I xx convert xx -resize xx.jpg Now my dir looks like this . .. a.png.jpg a.png b.png.jpg b.png c.png.jpg c.png The firs question is, how do i rename the file so that I can just have one extension. Not two. (basically, how do I clean up my original mistake)? The second question is, in the future, using xargs, how do I change the extension of the file simular to second command? how do i rename the file so that I can just have one extension. cd dir/with/messedup/files for file in *.png.jpg; do mv