|
1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 """ |
|
19 >>> from mode_plan import * |
|
20 >>> ls() |
|
21 <list of directory content> |
|
22 >>> ren('A01','A03') |
|
23 rename A010-joe.en.txt to A030-joe.en.txt |
|
24 accept [y/N]? |
|
25 """ |
|
26 |
|
27 def ren(a,b): |
|
28 names = glob.glob('%s*'%a) |
|
29 for name in names : |
|
30 print 'rename %s to %s' % (name, name.replace(a,b)) |
|
31 if raw_input('accept [y/N]?').lower() =='y': |
|
32 for name in names: |
|
33 os.system('hg mv %s %s' % (name, name.replace(a,b))) |
|
34 |
|
35 |
|
36 def ls(): print '\n'.join(sorted(os.listdir('.'))) |
|
37 |
|
38 def move(): |
|
39 filenames = [] |
|
40 for name in sorted(os.listdir('.')): |
|
41 num = name[:2] |
|
42 if num.isdigit(): |
|
43 filenames.append( (int(num), name) ) |
|
44 |
|
45 |
|
46 #print filenames |
|
47 |
|
48 for num, name in filenames: |
|
49 if num >= start: |
|
50 print 'hg mv %s %2i%s' %(name,num+1,name[2:]) |