Sophie

Sophie

distrib > Mageia > cauldron > x86_64 > media > core-release-src > by-pkgid > 3f322305d1e461ca028d87420119cdb7 > files > 24

dcraw-9.28.0-12.mga10.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 as xxx_todo_changeme:
      (errno,message) = xxx_todo_changeme.args
      print("Error renaming %s to %s: %s" % (name,new,message))

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

dodir(list)