tonight I grabbed my simplenote notes and moved them into my obsidian vault. The problem is that they are .txt files and not .md like the ones in obsidian. So I looked at some of the .md markdown obsidian notes and saw that they are actually just plain text unless I have added any actual markdown to them.
=> More informations about this toot | More toots from nxskok@mastodon.cloud
So I figured that I would just try renaming the .txt files to .md and see whether it worked. I remembered that mv is a pain because you can't just give it a bunch of files and say "change the extension of all of these files from .txt to .md", not at least without writing a shell script that I can never remember the format for without looking it up.
=> More informations about this toot | More toots from nxskok@mastodon.cloud
Hence, #rstats and the fs package, which I had never used before. I set dir_base to be the folder I wanted to work in, and then
dir_info(dir_base) %>% filter(str_detect(path, ".txt$")) %>% filter(str_detect(path, "T")) %>% pull(path) -> txtfiles txtfiles
dir_info returns info about all the files in the folder you give it. Then I used stringr to select the files I wanted to rename.
=> More informations about this toot | More toots from nxskok@mastodon.cloud
The easiest way I could think of to do the renaming was to make a dataframe with the old filenames in it, then construct the new ones:
tibble(oldname = txtfiles) %>% mutate(newname = str_replace(oldname, ".txt$", ".md")) -> dd
=> More informations about this toot | More toots from nxskok@mastodon.cloud
and then back to fs for the renaming, which went way more smoothly than I was expecting:
with(dd, file_move(oldname, newname))
Then I opened up obsidian, and all the newly renamed files were there as notes. (And were after a moment on my phone and my other computers).
Sometimes things do work nicely.
=> More informations about this toot | More toots from nxskok@mastodon.cloud
another thing that works unexpectedly well is that you can just bodily copy an R Markdown code chunk into a mastodon post and it formats it nicely. No need for screenshots or the like.
=> More informations about this toot | More toots from nxskok@mastodon.cloud
@nxskok {fs} is so underated
=> More informations about this toot | More toots from josi@fosstodon.org
@nxskok FYI rename is either available or installable on a lot of platforms...
rename 's/.txt/.md/' *.txt
=> More informations about this toot | More toots from jonocarroll@fosstodon.org This content has been proxied by September (ba2dc).Proxy Information
text/gemini