You need to escape or quote the entries: for f in *.PDF do base=`basename "${f} .PDF` mv "${f}" "${base}.pdf" done That works fine for me. Wing. On Thu, May 14, 2009 at 7:26 AM, Charles Howse <chowse at charter.net> wrote: > Hi, > 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? > > > -- > Thanks, > Charles > > Signs you're getting old... > A $4.00 bottle of wine is no longer "pretty good stuff". > > _______________________________________________ > X-Unix mailing list > X-Unix at listserver.themacintoshguy.com > http://listserver.themacintoshguy.com/mailman/listinfo/x-unix > -- Wing Wong wingedpower at gmail.com http://www.wingedpower.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://listserver.themacintoshguy.com/pipermail/x-unix/attachments/20090522/a09a0704/attachment-0001.html