-
Notifications
You must be signed in to change notification settings - Fork 7
/
jos.py
27 lines (18 loc) · 962 Bytes
/
jos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#James os library for utilizing python os library
import os
def _mfren_r0( src_startwith, dst_startwidh):
if len( src_startwith) != len( dst_startwidh):
raise Typeerror('The lengths of src_startwith and dst_startwith strings must be the same.')
fnames = os.listdir(".")
fnames_Tang = [x for x in fnames if x.startswith( src_startwith)]
fnames_Tang2Tong = [ dst_startwidh+x[len(dst_startwidh):] for x in fnames if x.startswith( src_startwith)]
for src, dst in zip( fnames_Tang, fnames_Tang2Tong):
print src, '-->', dst
os.rename( src, dst)
def mfren( src_startwith, dst_startwidh):
fnames = os.listdir(".")
fnames_Tang = [x for x in fnames if x.startswith( src_startwith)]
fnames_Tang2Tong = [ dst_startwidh + x[len( src_startwith):] for x in fnames_Tang]
for src, dst in zip( fnames_Tang, fnames_Tang2Tong):
print src, '-->', dst
os.rename( src, dst)