Determining if a filename is greater than X characters
hokiegal99
hokiegal99 at vt.edu
Sun Aug 3 16:03:28 EDT 2003
Thanks for the tips. I got it to work using this:
for root, dirs, files in os.walk(setpath):
old_fname = files
new_fname = old_fname[0][:27]
print old_fname
print new_fname
The problem with this approach is that it only gets the first filename
in the directory. I tried doing "old_fname[:][:27]", but that doesn't do
it. I need to learn more about lists.
Thanks!!!
Irmen de Jong wrote:
> Cy Edmunds wrote:
>
>> filename = "abcdefgh"
>> if len(filename) > 6:
>> filename = filename[:6]
>> print filename
>> abcdef
>
>
> The if is not necessary, just use
>
> filename=filename[:6]
>
> --Irmen
More information about the Python-list
mailing list