removing spaces from front and end of filenames

Erik Max Francis max at
Sun Jul 13 03:49:47 CEST 2003

hokiegal99 wrote:

> This script works as I expect, except for the last section. I want the
> last section to actually remove all spaces from the front and/or end
> of
> filenames. For example, a file that was named "  test  " would be
> renamed "test" (the 2 spaces before and after the filename removed).
> Any
> suggestions on how to do this?

That's what the .strip method, which is what you're using, does.  If
it's not working for you you're doing something else wrong.

   Erik Max Francis && max at &&
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ The meaning of life is that it stops.
\__/  Franz Kafka

More information about the Python-list mailing list