How to rename files without changing extension in Linux 102221.pdf to 102221_name.pdf

前端 未结 3 1292
时光取名叫无心
时光取名叫无心 2021-01-16 09:46

How to rename files without changing extension in Linux \\

102221.pdf to 102221_name.pdf

3条回答
  •  有刺的猬
    2021-01-16 10:11

    This is what you want I think:

    for x in *; do mv "$x" "${x%.*}_name.${x##*.}"; done
    
    • ${x%.*} will give the name of the file without extention
    • ${x##*.} will extract the extentions

提交回复
热议问题