Step wtfk: Accidentally delete htaccess file without a


RewriteOptions inherit
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
# Remove trailing slash from URLs
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [L,R=301]
# php -- BEGIN cPanel-generated handler, do not edit
# This domain inherits the “PHP” package.
# php -- END cPanel-generated handler, do not edit
RewriteCond %{HTTP_HOST} ^sjgknight\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.sjgknight\.com$
RewriteRule ^finding\-knowledge\/wp\-content\/uploads\/\(\.\*\)\$\/?(.*)$ "http\:\/\/sjgknight\.com\/assets\/uploads\/\$1$1" [R=301,L]
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^finding\-knowledge\/cv\/$ "https\:\/\/sjgknight\.com\/about\/cv" [R=301,L]
RewriteCond %{HTTP_HOST} ^sjgknight\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.sjgknight\.com$
RewriteRule ^finding\-knowledge\/feed\/$ "http\:\/\/sjgknight\.com\/finding\-knowledge\.xml" [R=301,L]
RewriteCond %{HTTP_HOST} ^sjgknight\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.sjgknight\.com$
RewriteRule ^finding-knowledge/(\d{4})/(\d{2})/?(.*)$$1-$2-$3 [NC,R=301,L]
<IfModule mod_speling.c>
    CheckCaseOnly On
    CheckSpelling On
Link to original

I wanted to replace all instances of: _4626-550x367.jpg with: _-\d{3}x300 OR _-\300xd{3}

Step 10:





Step 9: … Find:

\[<img src="\/static\/(\d{4}\/\d{2}\/[^"]+)"[^>]+\/>]\(([^)]+)\)



Step 8: Yes this could be more efficient, replace the remaining html images Find:




Step 7: Replace other image links Notepad++ again Find:




Step 6: Replace featured_image frontmatter with updated link Using Notepad++ regex search, with ”. matches newline” ticked Find:

(featured_image: )(/static\/\d{4}\/\d{2}\/.*?)



Step 5: Use FTP to download uploads from Wordpress install, and replace links in the markdown

Using Notepad++ regex search, with ”. matches newline” ticked




This might leave behind some duplicates (for me at least, I had embeds followed by download buttons).

Step 4: Replace ‘categories’ with tags (because Obsidian can only handle one ‘tag’ type field) This’ll do it:

# assumes yaml, ymlthis, stringr, readr, and magrittr are installed
# Define a function to manipulate the yaml items
manipulate_yaml <- function(file) {
  # Read the yaml from the file
  y <- readr::read_file(file) 
  y <- stringr::str_split(y, pattern = "---") %>% .[[1]]
  content <- y %>% 
  y <- y %>% 
    .[2] %>% 
  #y <- read_yaml(file)
  # Get the items between categories and tags
  items <- y$categories
  # Prepend categories/ to each item
  items <- paste0("category/", items)
  # Replace categories with tags
  y$tags <- append(y$tags, items)
  # Remove categories
  #y$categories <- NULL
  # Remove the second occurrence of tags
  #y$tags <- y$tags[1]
  #make the header text again
  y <- strsplit(yaml::as.yaml(y), "\n")
  # Return the modified file
  y <- c("---\n", y[[1]], "\n---\n", content, "\n")
# Get the paths of all .md files in a given directory
# You can change the directory to your desired one
dir <- "C:/.../"
files <- list.files(dir, pattern = "\\.md$", full.names = TRUE)
# Apply the function to each file and write the modified yaml back to the file
lapply(files, function(file) {
  # Manipulate the yaml
  y <- manipulate_yaml(file)
  # Write the yaml back to the file
  readr::write_lines(x = y,

Step 3: Ensure the url string follows the : in the footnote: Find: (?<!\r[[:blank:]]|\n[[:blank:]])(\[\^)(\d+)(]:)(\n|\r|\R)(\S+) Replace: \1\2\3 \5

Step 2: Replace footnotes not preceded by a newline using: Find: (?<!\r[[:blank:]]|\n[[:blank:]])(\[\^)(\d+)(]:) Replace: \r\1\2\3\4

Step 1: Replace footnotes with [\d] form with [^\d] form Find: (\[)(\d+)(]) Replace: \[\^(\2)]

Step 0: First I used either the Wordpress export to Hugo plugin or the Wordpress export to Gatsby…I’ve forgotten. The markdown was pretty messy, so I ran the below (and then the regex above using notepad++…I forget which of these two:

  1. node ./content/tomd.cjs
  2. node ./content/tomdpan.cjs


PATH: "vault://tomd.cjs"
TITLE: "tomd.cjs" 


PATH: "vault://tomdpan.cjs"
TITLE: "and using pandoc tomdpan.cjs"