- Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathbulkeditor.py
executable file
·31 lines (25 loc) · 767 Bytes
/
bulkeditor.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
28
29
30
31
#!/usr/bin/env python
importos
importsys
tmpname="tmpname"
dirname=sys.argv[1]
filename=sys.argv[2]
path=dirname+"/"+filename
f=open(path, "rw+")
n=open(dirname+"/"+tmpname, "w")
filename=f.name
print"[+] opening {} for edit\n\n".format(path)
lines=f.readlines()
forlinrange(0, len(lines)-1):
if"!["inlines[l]:
corrected=lines[l].replace("\n","") +lines[l+1]
lines[l+1] =""
print"[+] correct inline image Markdown tag -> {}".format(corrected)
else:
corrected=lines[l]
n.write(corrected)
print"[+] remove original file"
os.remove(path)
print"[+] save edited copy with original filename -> {}".format(filename)
os.rename(dirname+"/"+tmpname, filename)
print"[+] done\n\n"