nvpy icon indicating copy to clipboard operation
nvpy copied to clipboard

refresh text files

Open stevepowell99 opened this issue 9 years ago • 2 comments

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?

stevepowell99 avatar Jul 15 '15 18:07 stevepowell99

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)

joereynolds avatar May 20 '18 13:05 joereynolds

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.

bobbyplubell avatar Oct 03 '18 21:10 bobbyplubell