cpbotha / nvpy

Simplenote syncing note-taking application, inspired by Notational Velocity and ResophNotes, but uglier and cross-platformerer.
Other
850 stars 112 forks source link

refresh text files #125

Open stevepowell99 opened 9 years ago

stevepowell99 commented 9 years ago

hi, I have disabled simplenote sync and am just using text files. I have a different script which adds new files to the folder, but nvpy can't see them until I close and reopen nvpy. Any ideas?

joereynolds commented 6 years ago

Can't help with the bug but can you share the script? I have about 100 plain text files that I'd like nvpy to pickup and I'm not sure how nvpy detects notes

Update: Nevermind, I wrote my own script which basically hacks a directory of files into a format nvpy is happy with

import os
import io
import json
import sys

try:
    path = sys.argv[1]
except IndexError:
    print("Please supply an absolute path to where your notes are stored")
    exit()

new_path = '/home/joe/.nvpy/'

for _file in os.listdir(path):
    try:
        file_content = io.open(path + _file, encoding = "utf-8").read()

        modification_time = os.path.getmtime(path + _file)

        nvpy_entry = json.dumps({
            'modifydate': modification_time,
            'tags': [],
            'createdate': modification_time,
            'syncdate': 0,
            'content': file_content,
            'savedate': modification_time
        })

        file_object = open(new_path + _file + '.json', 'w')
        file_object.write(nvpy_entry)

    except UnicodeDecodeError:
        print("Failed to read file: " + path + _file)
bobbyplubell commented 6 years ago

Hey for anyone else having similar troubles with the txt format, I found a config option called notes_as_txt that you can set as notes_as_txt = 1 to get nvpy to pick up txt files. I wasn't able to get it to pick up my .txt files from NV but this option makes it pull them in properly.