On Thu, May 14, 2009 at 09:26:19AM CDT, Charles Howse <chowse at charter.net> wrote: > > I need to batch rename all files with extension .PDF to extension .pdf. > They may or may not have spaces in the filenames. > > The following works ONLY if there are no spaces in the filename: > > for f in *.PDF; do > base=`basename $f .PDF` > mv $f $base.pdf > done > > Can anyone provide a tip to something that will work regardless of > whether there are spaces in the filenames or not? Use quotation marks to help protect spaces. for f in *.PDF; do base=`basename "$f" .PDF` mv "$f" "$base.pdf" done For the more curious, man bash and check out the lengthy section titled EXPANSION. -- Eugene http://www.coxar.pwp.blueyonder.co.uk/