I've got an issue where i'm trying to change names of a bunch of files in python. I've scoured the necessary directory and added the files to a list, and now im trying to remove the last 9 charecters from the filename and replace them with something new. When I try to take the letters off using fname =fname[-:9] its throwing me an error.
here's what i've got so far. Thanks for the help.
here's what i've got so far. Thanks for the help.
Code:
import os, sys, string
start = 'start path'
list = []
new_list = []
for dirs in os.walk(start):
list.append(dirs)
print list
print 'done'
for fname in list:
if '.pyw' in fname:
fname = fname[:-9]
new_list.append(fname)
print new_list
Comment