-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfname1.py
More file actions
38 lines (31 loc) · 1.08 KB
/
fname1.py
File metadata and controls
38 lines (31 loc) · 1.08 KB
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
32
33
34
35
36
37
38
# ------------------------------------------------------------------------------
# Python Scripts scriptarium/[fname1.py]
# (c) balarabe@protonmail.com
# ------------------------------------------------------------------------------
import os, binascii
os.chdir('T:\\eBooks') # <- only uncomment for debugging
lines1 = []
lines2 = []
with open("list.txt", mode='r', encoding='ansi') as fl:
data = fl.read()
src_lines = data.split('\n')
for ln in src_lines:
if ln == "" or (ln.find('.epub') == -1 and ln.find('.mobi') == -1):
continue
id = str(binascii.b2a_hex(os.urandom(16)))[2:34]
#
s = id + ' ' + ln
lines1.append(s)
#
j = ln.rfind('\\')
if j > -1:
ln = ln[j+1:]
s = id + ' ' + ln
lines2.append(s)
with open("list1.txt", 'wb') as fl:
s = '\n'.join(lines1) + '\n'
fl.write(s.encode('utf8'))
with open("list2.txt", 'wb') as fl:
s = '\n'.join(lines2) + '\n'
fl.write(s.encode('utf8'))
# end