简体   繁体   中英

Remove string from all filenames in Linux folder

I have folder with 1000 JPG files like this:

17.png.jpg
341.png.jpg
882.png.jpg
997.png.jpg
1023.png.jpg

I need to rename all the list so the number will stay and remove just the ".png" Result expected:

17.jpg
341.jpg
882.jpg
997.jpg
1023.jpg

What is the linux/mac command I should run?

If you have bash available, you can type

for i in *.png.jpg
do 
    mv "$i" "${i%.png.jpg}.jpg"
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM