Sunday, November 1, 2009

bash Script to remove string from filename

This bash script is to remove or replace a string from the filename.

#!/bin/bash

for THISFILE in *
do
filename=${THISFILE%\.*}
extension=${THISFILE##*\.}
newname=${filename//./_}
echo "mv $THISFILE ${newname}.${extension}"
#mv $THISFILE ${newname}.${extension}
done



---

No comments:

Post a Comment

Feel free to leave your question or comment here, we will reply you as soon as possible.