All of us know that files can be batch renamed using a for loop as under:
for file in *.xml; do mv $file `echo $file | sed 's/xml/html/'`; done
but
Kapil Raj on Unix forum suggested a nifty way to do it without a loop
ls -1 *.xml | nawk -F ".xml" '{print "mv ", $1".xml",$1}' | ksh
Explanation:ls -1 ---- lists the files vertically
nawk -F ".xml" '{print "mv ", $1".xml",$1}' ---- gets the input from ls -1 and treats .xml as the delimiter. So, if the file name is abc.xml.pqr then $1 would have abc and $2 would have pqr. Also awk prepares the input for a shell (ksh) in the format mv abc.xml.pqr abc.pqr
ksh ---- receives input from nawk and executes mv abc.xml.pqr abc.pqr (renames)
Note: This process is not recursive.Recursiveness can be obtained by using unix find command.
Ideas and comments are welcome