Ancestors

Toot

Written by Ken Butler on 2024-11-15 at 04:44

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

Descendants

Written by Ken Butler on 2024-11-15 at 04:46

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

Written by Ken Butler on 2024-11-15 at 04:50

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

Written by Ken Butler on 2024-11-15 at 04:51

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

Written by Ken Butler on 2024-11-15 at 04:54

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

Written by Ken Butler on 2024-11-15 at 05:01

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

Written by Josiah on 2024-11-15 at 05:03

@nxskok {fs} is so underated

=> More informations about this toot | More toots from josi@fosstodon.org

Written by Jonathan Carroll on 2024-11-15 at 05:21

@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

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113485142373910022
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
281.884598 milliseconds
Gemini-to-HTML Time
1.88182 milliseconds

This content has been proxied by September (ba2dc).