How can I batch rename files using the Terminal?

后端 未结 10 1742
情歌与酒
情歌与酒 2020-12-12 17:43

I have a set of files, all of them nnn.MP4.mov. How could I rename them so that it is just nnn.mov?

10条回答
  •  遥遥无期
    2020-12-12 18:32

    for i in *; 
    do j=`echo $i | cut -d . -f 1`; 
    j=$j".mov";
    mv $i $j; 
    done
    

    this will cut everything before the first dot and appends .mov

    but if some files are e.g. hi.2.mov and hi.1.mov one will be overwritten, so use it carefully ^^

提交回复
热议问题