Example #1
0
def collect_dir(dir, args):
    for f in recglob(dir + "/*.{jpeg,jpg,JPG,mov,MOV,png,PNG}"):
        collect_file(f, args)
Example #2
0
	while True:
		try:
			s = raw_input(text)
			return convfunc(s)
		except Exception, e:
			print "Error:", e

def str_to_bool(s):
	if s.lower() in ["y", "yes", "ja", "j", "1"]: return True
	if s.lower() in ["n", "no", "nein", "0"]: return False
	raise Exception, "I don't understand '" + s + "'; please give me an Y or N"
	
files = {}
errors = {}

for f in recglob(dir + "/*.{jpeg,jpg,JPG,mov,MOV,png,PNG}"):
	try:
		info = iminfo(f)
		prefix = info["DateTime"].replace(":", "_")[0:10] # get eg. "2011_01_22"
		prefix += "__"
		newfn = os.path.dirname(f) + "/" + prefix + os.path.basename(f)
		if os.path.exists(newfn):
			errors[f] = os.path.basename(newfn) + " already exists"
		elif os.path.basename(f)[0:len(prefix)] == prefix:
			errors[f] = os.path.basename(f) + " already has the prefix '" + prefix + "'"			
		else:
			files[f] = newfn
	except Exception, e:
		errors[f] = str(e)

while True:
Example #3
0
def collect_dir(dir, args):
	for f in recglob(dir + "/*.{jpeg,jpg,JPG,mov,MOV,png,PNG}"):
		collect_file(f, args)
Example #4
0
            s = raw_input(text)
            return convfunc(s)
        except Exception, e:
            print "Error:", e


def str_to_bool(s):
    if s.lower() in ["y", "yes", "ja", "j", "1"]: return True
    if s.lower() in ["n", "no", "nein", "0"]: return False
    raise Exception, "I don't understand '" + s + "'; please give me an Y or N"


files = {}
errors = {}

for f in recglob(dir + "/*.{jpeg,jpg,JPG,mov,MOV,png,PNG}"):
    try:
        info = iminfo(f)
        prefix = info["DateTime"].replace(":",
                                          "_")[0:10]  # get eg. "2011_01_22"
        prefix += "__"
        newfn = os.path.dirname(f) + "/" + prefix + os.path.basename(f)
        if os.path.exists(newfn):
            errors[f] = os.path.basename(newfn) + " already exists"
        elif os.path.basename(f)[0:len(prefix)] == prefix:
            errors[f] = os.path.basename(
                f) + " already has the prefix '" + prefix + "'"
        else:
            files[f] = newfn
    except Exception, e:
        errors[f] = str(e)