#!/usr/bin/python # # nautilus2lowercase.py # # Author Brad Emerson March 2007 # brad@emerika.com # www.emerika.com # # This work is hereby released into the Public Domain. To view a copy of the # public domain dedication, visit http://creativecommons.org/licenses/publicdomain/ # or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, # California, 94105, USA. # # Use at your own risk. import os import sys import re import urllib from os.path import basename, dirname, isfile from string import rstrip, lstrip, strip, replace, split, find, join from string import lower as tolower def main(): flist = os.environ[ 'NAUTILUS_SCRIPT_SELECTED_URIS' ] flist = flist.split() for item in flist: item = urllib.unquote(item) test = item[:7] rest = item[7:] if test == 'file://': # This test is just to be sure the input is as expected from Nautilus. name = basename(rest) path = dirname(rest) path = urllib.unquote(path) src = path + '/' + name dst = path + '/' + tolower(name) if src != dst and isfile(src) and not isfile(dst): os.rename(src, dst) if __name__ == "__main__": main()