counter = 1

for eachDirectory in attachmentsDirectoryNames:
    #if counter < 1795:
    #    counter = counter + 1
    #    continue

    #if eachDirectory.find("MOONGIFT") != -1:
    #    counter = counter + 1
    #    continue

    originalDirectoryName = eachDirectory

    # directoryAsFoundInMd = unicode("![](" + urllib.quote(eachDirectory.encode('utf8')))
    eachDirectory = bearEscapeDirectoryName(eachDirectory)

    directoryAsFoundInMd = unicode("![](" + eachDirectory + "/")

    noteFilePath = notesPath + "/" + originalDirectoryName + ".md"
    try:
        with codecs.open(noteFilePath, 'r', encoding='utf-8') as file:
            data = file.read()
            file.close()
            if data.find(unicode("![")) == -1:
                print("")
                print(directoryAsFoundInMd)
                print("counter: " + str(counter))
                print("####### the file " + noteFilePath +" exists but does not contain ANY link")
            elif data.find(directoryAsFoundInMd) == -1:
                print(directoryAsFoundInMd)
コード例 #2
0
notesFileNames = getNotesFileNames(notesPath)
attachmentsDirectoryNames = getAttachmentsDirectoryNames(notesPath)

FIX_DIRECTORIES = True

for eachDirectory in attachmentsDirectoryNames:

    #if eachDirectory.lower().find("untitled note".lower()) == -1:
    #    #print("skipping " + eachDirectory)
    #    continue

    originalDirectoryName = eachDirectory
    originalDirectoryPath = notesPath + originalDirectoryName

    # directoryAsFoundInMd = unicode("![](" + urllib.quote(eachDirectory.encode('utf8')))
    eachDirectory = bearEscapeDirectoryName(eachDirectory)

    directoryAsFoundInMd = unicode("![](" + eachDirectory + "/")

    howManyFilesPointToDir = 0
    notesPointingToDir = []
    for noteFileName in notesFileNames:
        noteFilePath = notesPath + "/" + noteFileName

        with codecs.open(noteFilePath, 'r', encoding='utf-8') as file:
            data = file.read()
            file.close()

            if data.lower().find(directoryAsFoundInMd.lower()) != -1:
                notesPointingToDir.append(noteFileName)
                howManyFilesPointToDir = howManyFilesPointToDir + 1
コード例 #3
0
from helper_routines import getFileNames
from helper_routines import bearEscapeDirectoryName

parser = argparse.ArgumentParser(description="My parser")
parser.add_argument('path')
args = parser.parse_args()

imagesPath = os.path.join(args.path,
                          '')  # add trailing slash if it's not there
imageFiles = getFileNames(imagesPath)

fse = sys.getfilesystemencoding()
imagesDirectoryName = unicode(ntpath.basename(os.path.normpath(imagesPath)),
                              fse)

#print(imagesDirectoryName)

noteContents = "# " + imagesDirectoryName + "\n"

for eachImageFile in imageFiles:

    if eachImageFile == ".DS_Store":
        continue
    noteContents = noteContents + "\n\n![](assets/" + bearEscapeDirectoryName(
        imagesDirectoryName) + "/" + bearEscapeDirectoryName(
            eachImageFile) + ")"

with codecs.open(imagesDirectoryName + ".md", 'w', encoding='utf-8') as fileW:
    fileW.write(noteContents)
    fileW.close()
parser.add_argument('imageFiles', nargs='+')
parser.add_argument('-v', '--vault-path')
args = parser.parse_args()

notesPath = os.path.join(args.vault_path,
                         '')  # add trailing slash if it's not there

fse = sys.getfilesystemencoding()

for f in args.imageFiles:
    print(f)

    eachImageFileName = unicode(ntpath.basename(os.path.normpath(f)), fse)
    if eachImageFileName == ".DS_Store":
        continue

    eachImageFileName_noExtension = os.path.splitext(eachImageFileName)[0]
    noteContents = "# " + eachImageFileName_noExtension + "\n\n![](assets/" + bearEscapeDirectoryName(
        eachImageFileName_noExtension) + "/" + bearEscapeDirectoryName(
            eachImageFileName) + ")"

    with codecs.open(notesPath + eachImageFileName_noExtension + ".md",
                     'w',
                     encoding='utf-8') as fileW:
        fileW.write(noteContents)
        fileW.close()

    imageDestinationPath = notesPath + "assets/" + eachImageFileName_noExtension
    os.mkdir(imageDestinationPath)
    copyfile(f, imageDestinationPath + "/" + eachImageFileName)
コード例 #5
0
    if len(assetsFiles) == 0:
        print("      WARNING: NO ASSETS (directory can be deleted?) " + originalDirectoryPath)
"""

for eachDirectory in attachmentsDirectoryNames:

    #if eachDirectory.lower().find("illustrated group theory".lower()) == -1:
    #    #print("skipping " + eachDirectory)
    #    continue

    originalDirectoryPath = notesPath + eachDirectory

    eachDirectoryStem = eachDirectory.rstrip().rstrip(string.digits).rstrip()

    # plainReferencesToDirectory = unicode("![](" + urllib.quote(eachDirectory.encode('utf8')))
    eachDirectory_bearEscaped = bearEscapeDirectoryName(eachDirectory)
    eachDirectory_bearEscaped_lower = eachDirectory_bearEscaped.lower()

    plainReferencesToDirectory = unicode("![](" + eachDirectory_bearEscaped +
                                         "/")
    plainReferencesToDirectory_lower = plainReferencesToDirectory.lower()

    referencesToDirectoryCount = 0
    notesPointingToDir = []

    for noteFileName in notesFileNames:

        if noteFileName[:-3].lower() != eachDirectory.lower():
            continue

        #if noteFileName.lower().find(eachDirectoryStem.lower()) == -1: