如何将所有扩展文件从.txt更改为.ascii?

时间:2017-03-27 14:31:11

标签: linux

我想通过脚本将所有文件扩展名从.txt更改为.ascii。 这是我的剧本:

#!/bin/bash

if [ $1 ]
then
        dir=$1
else
        echo -n "The director is: "
        read dir
fi

list=`find $dir -name \*.ascii`
for file in $list
do
        name=`basename $file .ascii`
        changedName=$name".txt"
        mv $file $changedName
done

此脚本移动脚本目录中的所有.txt文件,扩展名更改为.ascii ...我希望所有.txt文件都在原始目录中,扩展名更改为.ascii。

0 个答案:

没有答案