-
Notifications
You must be signed in to change notification settings - Fork 3
/
change-all-notes-path.py
44 lines (31 loc) · 1.32 KB
/
change-all-notes-path.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
44
# coding=utf-8
# Example:
# python change-all-notes-path.py /Users/davidedellacasa/Public/10000notes -n /Users/davidedellacasa/Desktop/Davide/notes-vault -f
from helper_routines import creation_date
from helper_routines import modification_date
from helper_routines import access_date
from helper_routines import checkPath
from helper_routines import getNotesFileNames
from helper_routines import stripEmptyTailLines
from helper_routines import changeNoteNameAssetDirNameAndAssetsLinks
import sys
import os
import codecs
from datetime import datetime
import math
import argparse
import time
parser = argparse.ArgumentParser(description="My parser")
parser.add_argument('path')
parser.add_argument('-f', '--fix-notes', action='store_true')
parser.add_argument('-n', '--new-path')
parser.add_argument('-v', '--verbose')
args = parser.parse_args()
notesOldPath = os.path.join(args.path, '') # add trailing slash if it's not there
checkPath(notesOldPath)
notesNewPath = os.path.join(args.new_path, '') # add trailing slash if it's not there
checkPath(notesNewPath)
notesFileNames = getNotesFileNames(notesOldPath)
for noteFileName in notesFileNames:
noteFilePath = notesOldPath + noteFileName
changeNoteNameAssetDirNameAndAssetsLinks(args.fix_notes, args.verbose, notesOldPath, noteFileName[:-3], noteFileName[:-3], notesNewPath)