10/01/2007

unix shellscript for renaming multiple files by removing a string from all filenames


# folder: no trailing slash $1
# str: string to remove $2

folder=$1
str=$2
echo $folder $str

files=`ls -1 $folder`
for file in $files ; do
echo $file
tc=`echo $file | sed s/$str//`
echo $tc
if [ -f $folder/$file ];
then
mv $folder/$file $folder/$tc
#echo $tc
#echo $folder/$file $folder/$tc
fi
done

exit 1

No comments:

Post a Comment