had(once more again) to massively remove some file extension from files
#!/usr/local/bin/python
# Remove extension from my files
# Author: mayia pi 2009
import os
extension = raw_input('enter the extension u want removed ?(without the dot):\n')
ext = '.' + extension
print 'search n destroy ' + ext + ' ...'
n = 0
for fname in os.listdir(os.getcwd()):
if fname[-len(ext):] == ext :
newfname = fname[:-len(ext)]
os.rename(fname, newfname)
print fname + ' renamed ' + newfname
n +=1
print ' --- ' + str(n) + ' files stripped'
...now i also need a nice ftp script
comments
from
mari@pi 2009-04-14 10:59

it works! hoooreii
from
mari@pi 2009-05-06 14:36

reverse ...
#!/usr/local/bin/python
# add extention to my files
# Author: mayia pi 2009
import os
extention = raw_input('enter the extention u want added (without the dot):\n')
ext = '.' + extention
print 'adding ' + ext + ' to everything...but .py'
n = 0
for fname in os.listdir(os.getcwd()):
if fname[-2:] <> 'py' :
newfname = fname + ext
os.rename(fname, newfname)
print fname + ' renamed ' + newfname
n +=1
print ' --- ' + str(n) + ' files renamed '