-
Notifications
You must be signed in to change notification settings - Fork 0
/
oneExporter.py
43 lines (35 loc) · 1.3 KB
/
oneExporter.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
32
33
34
35
36
37
38
39
40
41
42
43
"""
This script accepts a directory as a parameter and will recursively search for
and convert .one (OneNote) files to .pdf files.
A variable can be set to exclude specific directory names from search.
"""
__author__ = ["Dietmar Malli"]
__copyright__ = "Copyright 2017, Dietmar Malli"
__credits__ = []
__license__ = "GPLv3"
__version__ = "1.0.1"
__maintainer__ = ["Dietmar Malli"]
__email__ = ["[email protected]"]
__status__ = "Production"
import os
import subprocess
import sys
from sharedExporterFunctions import get_output_path, newer_as, get_recursive_filelist
# Folders to exclude from OneNote file scan:
folders_to_exclude = ['.dropbox.cache']
# Find root folder:
root_folder = './'
if len(sys.argv) > 1:
root_folder = sys.argv[1]
# Scan current folder recursively for .one and .jnt files:
one_list = get_recursive_filelist(filebase=root_folder, exclude_folders=folders_to_exclude)
# Print the .one files:
for one_file in one_list:
output_path = get_output_path(one_file)
if newer_as(one_file, output_path):
print('Printing {}'.format(one_file))
# Remove old .pdf file first. AutoIT script assumes it to be removed:
os.remove(output_path)
subprocess.call(['exportPDF.exe', one_file, output_path])
# Close OneNote if it is opened:
subprocess.call(['closeOneNote.exe'])