Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > eac1c6ac9da3d228dba0e45fcd8e9a89 > files > 20

dcraw-9.28.0-2.1.mga7.src.rpm

#!/usr/bin/python
# Lowercase a list of filenames and change spaces to underscores.
# Directories are descended recursively.
# Dave Coffin  12/14/99

from os import *
from os.path import *
from string import *
import exceptions
import errno
import sys

def dodir(list):
  for name in list:
    if isdir(name) and not islink(name):
      orig = getcwd()
      chdir(name)
      dodir(listdir("."))
      chdir(orig)
    new = replace(lower(name)," ","_")
    if new == name: continue
    try:
      rename(name,new)
    except OSError, (errno,message):
      print "Error renaming %s to %s: %s" % (name,new,message)

list = sys.argv[1:]
if list==[]: list=["."]

dodir(list)