shell脚本:批量修改文件扩展名 | 您所在的位置:网站首页 › shell脚本的后缀名 › shell脚本:批量修改文件扩展名 |
上周有个学生问我,在LINUX下怎么用SHELL脚本实现批量更改扩展名。 在消耗少量脑细胞后,写了一个简单的脚本供大家参考。 #/bin/bash read -p "what extendname you want to change: " exname \\给出想修改的扩展名 read -p "you want to change to: " new \\给出新的扩展名 read -p "please tell me the directory: " dir \\给出文件所在目录 cd $dir for file in $(ls $dir | grep .$exname) do name=`ls $file | cut -d. -f1` mv $file ${name}.$new done 本文出自 “凯旋之歌” 博客,请务必保留此出处http://kaiserwu.blog.51cto.com/697390/525099 |
CopyRight 2018-2019 实验室设备网 版权所有 |