Skip to content

Commit

Permalink
feat: split into a group
Browse files Browse the repository at this point in the history
  • Loading branch information
decaf-dev committed Dec 5, 2023
1 parent d98a6e9 commit 5000e7b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ export default class NoteSplitterPlugin extends Plugin {
}

try {
this.app.vault.createFolder("note-splitter");
await this.app.vault.createFolder("note-splitter");
} catch (err){
//Folder already exists
}

const currentTime = Date.now();
try {
await this.app.vault.createFolder(`note-splitter/group-${currentTime}`);
}catch(err){
//Folder already exists
}

for (let i = 0; i < split.length; i++) {
const line = split[i].trim();
await this.app.vault.create(
`note-splitter/split-note-${Date.now() + i}.md`, line
`note-splitter/group-${currentTime}/split-note-${Date.now() + i}.md`, line
);
}
new Notice("Split into " + split.length + " note" + (split.length > 1 ? "s" : ""));
Expand Down

0 comments on commit 5000e7b

Please sign in to comment.