Determining if a filename is greater than X characters

hokiegal99 hokiegal99 at vt.edu
Sun Aug 3 22:30:27 EDT 2003


One last question and then I'll leave you guys alone for awhile: How 
would I append a string to the end of each file that I've truncated? I'd 
like to put '.txt' on the end, but I don't understand how to go about 
it. When I tried this:

  old_fname = files
  new_fname = old_fname.append('.txt')

.txt was added as a string to the files list. Researching a bit on 
Google told me that in Python strings are unchangeable. So, how would I 
go about changing a string?

Thanks!!!


hokiegal99 wrote:
> 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!!!






More information about the Python-list mailing list