简体   繁体   中英

bash/terminal RH remove last 3 characters of filename

I have thousands of images in a folder and subdirectories, I tried to create a compress file of them all. Somehow I have inadvertently added .gz to the end of every image.

image1.jpg.gz
image2.jpg.gz
/Folder/image3.jpg.gz

Im trying to find the correct command to remove all of the .gz extension and keep the .jpg extension.

Any help greatly appreciated.

这可能应该工作。

find . -name '*.gz' -exec bash -c 'mv "${1%%.gz}"{.gz,}' - {} \;

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