shell批量修改当前目录及其子目录中文件后缀名称

    xiaoxiao2021-03-25  106

    #!/bin/bash function getdir(){ for element in `ls $1` do dir_or_file=$1"/"$element if [ -d $dir_or_file ] then getdir $dir_or_file else if test ${element##*.} = "png" then base=${dir_or_file%.png} mv $dir_or_file ${base}.$newext fi fi done } oldext="png" newext="data" root_dir=$(cd "$(dirname "$0")";pwd) echo $root_dir getdir $root_dir

    oldext是要替换的文件后缀,newext是要替换成的文件后缀

    转载请注明原文地址: https://ju.6miu.com/read-22929.html

    最新回复(0)