Skip to content

Instantly share code, notes, and snippets.

@gekh
Created May 30, 2013 13:21
Show Gist options
  • Save gekh/5677769 to your computer and use it in GitHub Desktop.
Save gekh/5677769 to your computer and use it in GitHub Desktop.
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