Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect function name in pop-up help for tp.file.move() #1136

Closed
SteveDockar opened this issue Jul 4, 2023 · 4 comments
Closed

Incorrect function name in pop-up help for tp.file.move() #1136

SteveDockar opened this issue Jul 4, 2023 · 4 comments
Labels
bug Something isn't working good first issue A good issue for someone who wants to contribute

Comments

@SteveDockar
Copy link

SteveDockar commented Jul 4, 2023

Plugin information (please complete the following information):

  • OS: [Windows 11]
  • Templater version: [1.16.0]
  • Obsidian version: [1.3.5]

Describe the bug
The pop-up help for tp.file.move() is incorrectly labelled (and so only appears) as tp.file.functions.move.

Expected behavior
Entering tp.file.m should suggest the tp.file.move() function.

Screenshots
image

Additional context
The pop-up help text correctly identifies the function's actual name, but is only triggered by the incorrect function name, and appears in the list of file module functions sorted under 'f' instead of 'm'. Hitting enter while the help text is displayed enters the incorrect tp.file.functions.move() string.

Checking /docs/documentation.toml shows the incorrect 'name' parameter in line 208.

[tp.file.functions.move]
name = "functions.move"
description = "Moves the file to the desired vault location."
definition = "tp.file.move(new_path: string, file_to_move?: TFile)"
@SteveDockar SteveDockar added the bug Something isn't working label Jul 4, 2023
@Zachatoo Zachatoo added documentation Improvements or additions to documentation good first issue A good issue for someone who wants to contribute and removed documentation Improvements or additions to documentation labels Oct 4, 2023
@mariusgerome
Copy link

mariusgerome commented Oct 9, 2023

Hey. I tried both options (tp.file.functions.move and tp.file.move) and both don't work. But I'm also just starting out with this stuff and I might be … stupid.

I have a folder named "_new" directly in my obsidian root. And I want newly created daily, weekly, monthly and yearly notes (by the periodic notes plugin) to be moved to "_new" after they got created. So I tried this:
<% tp.file.functions.move(/_new/, TFile) %>
and this:
<% tp.file.move(/_new/, TFile) %>
and a bunch of variations (with "/" and without etc…) but nothing seems to work when I trigger the "Replace Templates in Active File" Command.

Btw I don't even understand what "TFile" stands for :D "This file" ? Maybe. Hm, perhaps I need to insert some other value?
– M

@SteveDockar
Copy link
Author

SteveDockar commented Oct 9, 2023

I have a folder named "_new" directly in my obsidian root. And I want newly created daily, weekly, monthly and yearly notes (by the periodic notes plugin) to be moved to "_new" after they got created.

You don't need to get overly complex with this. You can include a path directly in the folder and format data for Periodic notes. I have a folder under root called Periodic-Notes and under that Daily-Notes, Weekly-Notes etc. In the Periodic Notes folder settings for Daily Notes I have Periodic-Notes/Daily-Notes then as I want sub-folders for Year/Month I then have the note (file name) format set to YYYY/MM/YYYY-MM-DD so each note file is still named for the Year-Month-Date, but is under a Year and then Month folder in my /Periodic-Notes/Daily-Notes folder(s).

I realise this isn't exactly what you're aiming to do, but you can use /_new in the Periodic Notes "Note Folder" setting(s) and then also specify sub-folders or specific naming formats in the Format setting(s).

If you do want to use Templater, you can apply the move instruction at the top of a template applied to the note. If I tag a contact using [[first last]] and then decide to actually create a contact note/file for that link, clicking on it creates the note in the vault's root. I then apply a 'person' template which as well as all the stuff I want for the new person file inside it, has

<%*
tp.file.move("/People/" + tp.file.title)
_%>

at the top, which moves the file to a new file in my /People folder with the same file name as the original. I think your issues were that you haven't quoted "/_new" which the function wants as a STRING, and you then need to tell the function what file to move, by passing a TFILE object which in simple terms is the title of a valid file. In my example I use tp.file.title to pass the current file, the one I'm applying this template to, to the function to say 'move this file in to "/this/" folder'.

I hope that helps.
Dox.

@mariusgerome
Copy link

First; thanks for the answer @SteveDockar

You've just gone as deep as I'm able to understand.
Around 15min, and countless tries later, I got it!! wuuw

<% tp.file.move("/_new/" + tp.file.title) %>

Buuut, why does the syntax looks like this: tp.file.move(new_path: string, file_to_move?: TFile)
if I need to add a "/" to the end of the folder and "+" instead of a "," … this is weird. But okay. It works.


I realise this isn't exactly what you're aiming to do, but you can use /_new in the Periodic Notes "Note Folder" setting(s) and then also specify sub-folders or specific naming formats in the Format setting(s).

Quick note on that: if I add a note-folder for my daily / weekly / … notes, I can't move them where ever I want, otherwise the shortcuts Periodic Notes: Open next/previous daily/weekly/… note won't work anymore. I assume the plugin is looking for this note-folder to perform this action – so if I place them files elsewhere, it misses them. And on the other hand if my root folder is / the obsidian root, I can access all of these hotkeys, no matter where my files are in my vault.


General question

I had to open my chrome history and search for this specific github link, because I didn't get a notification or something as I opened github.com. I'm an absolute rookie – therefore I haven't changed any auto subscriptions settings, meaning this "issue" got subscribed, but didn't left a notification in my inbox. Thats confusing, what do I do?
GitHub's in general confusing, so many things that unfold when you go one level deeper, damn. Like this "Issues" thing

Thanks for the help dude! :)
– M

@Zachatoo
Copy link
Collaborator

Thanks for the feedback on the docs being confusing. I updated the docs for tp.file.move to hopefully be a little more clear. Does it make more sense with the changes I made? Anything else you would change? There's also examples at the bottom of most pages that explain what each example is doing.

Link to tp.file.move docs: https://silentvoid13.github.io/Templater/internal-functions/internal-modules/file-module.html#tpfilemovenew_path-string-file_to_move-tfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue A good issue for someone who wants to contribute
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants