[X-Unix] Renaming files with spaces
Eric F Crist
ecrist at secure-computing.net
Fri May 22 08:56:16 PDT 2009
Put your file name in quotes.
for f in *.PDF; do
base=`basename $f .PDF`
mv "$f" "$base.pdf"
done
You could also do this with find and a proper 'exec' argument. Find
will take care of the escaping for you.
HTH
Eric
On May 14, 2009, at 9:26 AM, Charles Howse 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
>
---
Eric Crist
More information about the X-Unix
mailing list