├── Export-wiznote.py
├── LICENSE
└── README.md
/Export-wiznote.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 | from __future__ import print_function, unicode_literals
3 | from os import listdir, walk, mkdir, remove, chmod, makedirs
4 | from os.path import isfile, isdir, join, basename, exists
5 | from zipfile import ZipFile
6 | from shutil import rmtree
7 | from stat import S_IWRITE
8 | from time import sleep
9 |
10 | # 实现导出md文件夹
11 | wiz_path = 'F:/wiz_save/Data/350341849@qq.com/'
12 | export_path = 'F:/xx/'
13 | tmp_path = 'F:/'
14 | wiz_path_listdir = listdir(wiz_path)
15 |
16 | if exists(export_path):
17 | chmod(export_path, S_IWRITE)
18 | rmtree(export_path)
19 | sleep(0.1)
20 | mkdir(export_path)
21 | else:
22 | mkdir(export_path)
23 |
24 | # 生成目录
25 | for path in walk(wiz_path):
26 |
27 | if path[1] != []:
28 | for mkdir_path in path[1]:
29 | new_path = path[0].replace(wiz_path, export_path)
30 | new_path = join(new_path, mkdir_path)
31 | makedirs(new_path)
32 | # 生成md文件和文件夹之间的递归
33 |
34 |
35 | def chuli(new_file_path):
36 | ziw_path = listdir(new_file_path)
37 | for ziw in ziw_path:
38 | new_ziw_path = join(new_file_path, ziw)
39 | if isfile(new_ziw_path):
40 | print(new_ziw_path)
41 | zip_temp = ZipFile(new_ziw_path)
42 | zip_temp.extract('index.html', tmp_path)
43 | new_tmp_path = join(tmp_path, 'index.html')
44 | html = open(new_tmp_path, 'r')
45 | md = html.read().decode('UTF-16')
46 | md = md.replace('
', '')
47 | md = md.replace('', '')
48 | md = md.replace(' ', ' ')
49 | md = md.replace('
', '\n')
50 | new_export_path = new_ziw_path.replace(wiz_path, export_path)
51 | new_export_path = new_export_path[0:-4]
52 | print(new_export_path)
53 | makedown = open(new_export_path, 'w')
54 | md = md.encode('utf-8')
55 | makedown.write(md)
56 | makedown.close()
57 | html.close()
58 | chmod(new_tmp_path, S_IWRITE)
59 | remove(new_tmp_path)
60 |
61 | else:
62 | chuli(new_ziw_path)
63 |
64 | for file in wiz_path_listdir[2:]:
65 | file_path = join(wiz_path, file)
66 | if isdir(file_path):
67 | new_file_path = join(file_path,)
68 | if listdir(new_file_path) != []:
69 | chuli(new_file_path)
70 |
71 | print('over')
72 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2016,
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Export-wiznote
2 | 批量导出为知笔记中的markdown文件
3 |
4 | 使用环境:window+python2/3
5 |
6 | 使用要求:为知笔记的文件必须都是markdown文件或者纯文本文件
7 |
8 | 建议使用Editor.md来编辑markdown文件 避免出错
9 |
10 | 使用操作:使用前需修改ExpertToMd.py 三个参数
11 |
12 | wiz_path: 为知笔记用户数据目录
13 |
14 | tmp_path:使用中会生成一个临时文件,程序执行后自动删除,目录随意
15 |
16 | export_path:导出文件的位置
17 |
18 | 由于本脚本目前就我一个人使用,如果你在使用过程中出现任何问题,
19 | 请联系我的邮箱:350341849@qq.com
20 |
--------------------------------------------------------------------------------