Rename file with current date: Problem with cd'ing into current directory #369
-
I'd like to rename file
This moves the active file from However, if I want to do this to a note that isn't in the specified folder, this won't work because obviously the
This will rename the file correctly but will put it in the root directory of the vault. However, I can't figure out how to rename the file in place. Because with So the main thing would be to have a Is this possible? My goal is to eventually have a flexible shell script that would check if the file includes a string, e.g. But this is based on being Thanks! EDIT: Just discovered EDIT 2:
and does exactly what I wanted it to. It uses So now I'm still working on an if-clause that checks if the file being looked at doesn't already have a date in it, so it doesn't get two. Just aesthetically/visually, it would be easier if your plugin could be written with line breaks in them. Those seem to make the scripts unusable so it seems for now I'm stuck with one-liners. But, as I have no idea how difficult this would be to change, that's fine. What's more important: how do I tell the shell script to stay with the current note? When I have the above script move my file, Obsidian then opens another note (I can't tell why it chooses that other note). So Thanks :) |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
This is what I currently have for the check if there's a date in the file:
This does NOT work. A terminal window pops up but closes right away, so I don't get any error message. This is just for clarity, for the plugin, this needs to be turned into a one-liner. If anyone has any ideas what's breaking this, I'd appreciate it :) |
Beta Was this translation helpful? Give feedback.
-
I think this is working now:
I tried using negations e.g. ![2*] for the case that the file doesn't start with a number but this doesn't seem to work in the plugin, so "*" appears to match everything not matched by the previous case? Not sure I understood the tutorial correctly. If this doesn't work, I'll replace it with As a one-liner for the plugin this looks like this:
If anyone has any improvements, please let me know :) |
Beta Was this translation helpful? Give feedback.
-
I've now rewritten this in regular bash, and am now (so far unsuccessfully) trying to just have Shellcommands run it.
However, when I try putting that into Shellcommands, e.g. I also tried this with Could you please tell me how to fix this? Thank you!! |
Beta Was this translation helpful? Give feedback.
-
I ported the above script back into ShellCommands, and now it works, I think:
The Or because it's a lot easier on the eyes, when editing the code, I figured that I can also |
Beta Was this translation helpful? Give feedback.
-
Hmm, I think there a couple of things that could be considered to make your script multiline:
I didn't test the script, but it should show the general idea. The backslashes
|
Beta Was this translation helpful? Give feedback.
I ported the above script back into ShellCommands, and now it works, I think: