Added copy_from_file and copy_from_folder functions #1398
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds two functions:
copy_from_file
andcopy_from_folder
.Goal
These functions allow users to take already existing files with full content and copy them to a new location. Some use case for this include: Maintain a record of your notes over time, Copy the latest to do list you have to a new folder so you can update its existing content easily, Copy latest status sync info, 'Template' with existing notes, Use the content you already have in an existing note and keep that up to date, copy new associated files and link to them in your templated note, and more!
Sample usage
Copy the latest modified file from one folder to another
<%* await tp.file.copy_from_folder("Status Sync", "lastModified","Status Sync") %>
Snapshot a particular file and link to it
Todo snapshot: [[<% (await tp.file.copy_from_file("Todos.md", "Snapshots", "Todo-" + tp.date.now("YYYY-MM-DD"))).basename %>]]
Improvements
This PR needs improvements for these areas. If the initial idea looks good please let me know and then I can finish coding in rest of the required items which I believe are: