same question pretty much. im working on a script to rename files. I found a mp3 rename script as follows
Code:
if [ "$1" ]
then
if [ -d "$1" ]
then
cd "$1"
else
echo invalid directory
exit
fi
fi
for i in *
do
OLDNAME="$i"
NEWNAME=`echo "$i" | tr ' ' '_' | tr A-Z a-z | sed s/_-_/-/g`
if [ "$NEWNAME" != "$OLDNAME" ]
then
TMPNAME="$i"_TMP
echo ""
mv -v "$OLDNAME" "$TMPNAME"
mv -v "$TMPNAME" "$NEWNAME"
fi
done
Im wanting to ls a working folder and feed the directories that reside in the working area into the rename tool.
Here's what I have so far, the last sed statement keeps putting "$CURDIR" instead of the value of pwd.
Code:
CURDIR=$(pwd)
ls -R ./ *.mp3 | grep "./" | sed "s/:$//g" | sed s/^.\//$CURDIR/g
#For testing, will be removed once working
echo $CURDIR
The problem is in the last sed statement.
Thanks guys. Oh, and this is not homework...for fun as Linux should be! Once working I'll share the working vesion with a "for" loop.