Created
May 30, 2013 13:21
-
-
Save gekh/5677769 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
try: | |
t = sys.argv[1] | |
u = sys.argv[2] | |
rnm = True if len(sys.argv) > 3 else False | |
fl_st = sys.argv[0] | |
fl_n = fl_st.rfind("\\") | |
fl_name = fl_st[fl_n+1:] | |
except IndexError: | |
print("Запускай так:") | |
print('replace.py <Чт> <На чт замнить> [<Меняем>]') | |
else: | |
flist = os.listdir("./") | |
fcount = len(flist) | |
for i in range(fcount): | |
if not fl_name == flist[i]: | |
newName = flist[i].replace(t,u) | |
if rnm: | |
os.rename(flist[i],newName) | |
print(newName) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment