shell script to rename directory

substr in AWK to extract string[@more@]

#!/bin/bash
for file in *
do
showname=$file

if [ -d "$file" ] # Check if it's a directory.
then
# xxxx_report echo $showname | awk '{print substr($0,1,length($0)-7)}'
# cut ?only need xxxx
targetname=`echo $showname | awk '{print substr($0,1,length($0)-7)}'`
mv $showname $targetname
echo $file "has been changed"
fi

done

请使用浏览器的分享功能分享到微信等