I try to move a file based on a rule with Templater. Unfortunately the function tp.file.move(…) accepts only .md files. But I want to move a .pdf file too. Didn’t found a way yet to achive this.
Background: I use Obsidian (also) as a document vault (moved from Notion & Evernote). I put a .pdf into a folder: “/inbox/my-special.pdf” Than I create a new file “my-special.md” to store some meta-data. With templater I read the file name (which is much complexer (will show one at the end) and create a folder “archive/2020-2029/2023/my-special” and put both files (.md & .pdf) into it. This is a manual process so far, and I want to speed it up (a.k.a. automate it).
So I start from:
/inbox/2023-12-17 - Invoice (Car Repair) - My Repair Station - -250,00€.pdf
and want to go to:
- archive/2020-2029/2023/2023-12-17 - Invoice (Car Repair) - My Repair Station - -250,00€ // new folder based on file name-
- 2023-12-17 - Invoice (Car Repair) - My Repair Station - -250,00€.md // new meta-data file based on file name-- 2023-12-17 - Invoice (Car Repair) - My Repair Station - -250,00€.pdf // the original pdf moved into the destination folder based on file name
I want to keep the pdf and the “meta-data” together in one folder. I have (ten)thousands of those files imported from Evernote / Notion and wand to be “indipendent” and “non-propriatary”.
And of course, it’s easier to do some things outside of Obsidian. Get the robot to write a shell script (test the script in a small-scale environment first and otherwise make backups). Definitely need some automation for 10k+ files.
The chat robots are not to be trusted with such a task, and we shouldn’t give such advise. At least that is my opinion in order to not cause harm for someone asking for help.
…anybody to do mass-scale automation must indeed use caution.
But you know better than most around here that we cannot give them scripts without knowing their files, etc.
My idea was a general starting point. That’s as far as free advice can go.
I’m not sure tools like Directory Opus can be of help, but maybe, if he’s on Windows. But even there he’d need some script and he may not get it on their forum, either.
Otherwise, he needs to learn some of the ropes and get the job done, in, say, 3-6 months time.
Anybody who uses Obsidian is recommended to learn some scripting, regular expressions, DataView queries etc.
They do need to learn the ropes, as you put it, but that’s even a better reason not to suggest doing shell script generated by a chat robot. Hopefully it crashes before it’s destroyed the files of the end user, but the risk is just too high. Especially if the end user is not experienced with scripting at all.
You’ll most likely need to figure out the full path, but there exists functions like the getAbsolutePath() (I think it’s called) which is somewhere in the Obsidian API :-), and other utility functions which can be used to find the full path.
However, the automation of such a task do require some knowledge of both scripting and file handling, and I would strongly suggest not to use any chat robot to generate such a script and running it blindly on your file system. I’d rather take my time and search for similar topics in this (and other) forum(s), and build it up piece by piece. After all, messing with thousands of files is something you’ll need to do with care.
I do agree the robot (at least the free one) is not good quality and either tends to 1) dumb down to the level of the user (that’d be me, although many times I had to correct it myself, the non-coder) 2) to get into its apologizing mode I cannot stand or 3) pretends to understand to make the new modifications and gives you the same version again with not an iota of difference.
The best approach to use it is give a sample code with API and syntax working for people on this forum and when you detect it getting into its moods, start a new session.
There is indeed a lot of things wrong with it, but sometimes you get lucky and get a Python script that will work in 3-5 mins. If someone can read logic in the code, they can ask it to make something differently, etc.
Indeed, it is important to NOT BE LAZY about trying the code in a test environment first. Better safe than sorry.
I also didn’t think about of the usage of a chat robot.
I was once a dev by myself - in a prvious life. So I got a bit rusty.
I was just hoping to achive this with the templater plugin on the easy way - for the Obsidian API - I digged into it, but I didn’t found anything usefull I could used outside of a plugin.
About the scale:
I want tp apply those automations firstly on all new files. If this way is working I would go to a bit bigger scale, with a lot of error handling of course. Not all files are well formed as described above. I need to handle a lot of deviations.
But thanks for pointing me to the right direction.