Determining if a filename is greater than X characters

Cy Edmunds cedmunds at spamless.rochester.rr.com
Sat Aug 2 22:45:31 EDT 2003


"hokiegal99" <hokiegal99 at hotmail.com> wrote in message
news:93f5c5e9.0308021815.44c57a2d at posting.google.com...
> How would I determine if a filename is greater than a certain number
> of characters and then truncate it to that number? For example a file
> named XXXXXXXXX.txt would become XXXXXX
>
> fname = files
> if fname[0] > 6
>    print fname[0]
>
> Thanks!!!

filename = "abcdefgh"
if len(filename) > 6:
    filename = filename[:6]
print filename
abcdef

-- 
Cy
http://home.rochester.rr.com/cyhome/






More information about the Python-list mailing list