comparison bin/dumpshot @ 113:9b91e702c19c

Latestest merge.
author Edho Prima Arief <edho@myconan.net>
date Wed, 19 Oct 2011 06:51:43 +0000
parents 06ab5f0f9c28
children
comparison
equal deleted inserted replaced
88:917b525eaee0 113:9b91e702c19c
1 #!/usr/bin/env python
2
3 import sys, os, re
4
5 def is_shotfile(inpath):
6 finpath = os.path.basename(inpath)
7 return (finpath[-4:] == ".png") and (finpath[:4] == "shot")
8
9 def main(source_files, targetdir):
10 max_shot=0
11 try:
12 current_files=os.listdir(targetdir)
13 for current_file in current_files:
14 if is_shotfile(current_file):
15 file_shot = int(re.findall("\d+", current_file)[0])
16 if file_shot > max_shot:
17 max_shot = file_shot
18 for source_file in source_files:
19 if is_shotfile(source_file):
20 max_shot += 1
21 target_file = os.path.join(targetdir, "shot%04d.png" % max_shot)
22 print "Moving: %s => %s" % (source_file, target_file)
23 os.rename(source_file, target_file)
24 except:
25 print "(%s: %s)" % (sys.exc_type, sys.exc_value)
26
27 if __name__ == "__main__":
28 main(sys.argv[2:], sys.argv[1])