Created
May 6, 2021 01:25
-
-
Save mygeekdaddy/efdba93b5c3d1981dcdbd7f946127fde to your computer and use it in GitHub Desktop.
Drafts action to import .MD files and apply tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on original script from @agiletortoise on Drafts Forum | |
// https://forums.getdrafts.com/t/bulk-import-text-files/2852/8 | |
let fm = FileManager.createCloud(); | |
let path = "/Temp"; | |
let files = fm.listContents(path); | |
for (let f of files) { | |
// get file name from end of path | |
let fileName = f.split("/").pop(); | |
// read content of file | |
let content = fm.readString(f); | |
let nvtag = fileName.split(" ")[0] | |
// create draft | |
let d = Draft.create(); | |
d.content = fileName + "\n\n" + content; | |
d.addTag(nvtag); | |
d.addTag("nvalt") | |
//myStr.split(" ")[0] | |
d.update(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment