-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert-wp-html-to-markdown.sh
More file actions
34 lines (29 loc) · 984 Bytes
/
convert-wp-html-to-markdown.sh
File metadata and controls
34 lines (29 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/zsh
#rename html files to remove the date so it's just the title of the post (MAKE SURE TO CHANGE THE DATE!)
for file in 2022-01-11-*.html
do
mv "$file" "`echo $file | sed 's/2022-01-11-//'`"
done
#need something that will select all the html files in the folder and convert them to separate markdown files (this current one so far makes the MD files, but still has a wonky ".html" in the file name)
for FILE in *
do
reverse_markdown $FILE > "$FILE".md
done
#removes the .html files so only the .html.md files are left
for FILE in *.html
do
rm "$FILE"
done
#removes .html from the filenames
for FILE in *.html*
do
mv "$FILE" "`echo $FILE | sed 's/.html//'`"
done
#removes layout config (except post title) and word press comments
for FILE in *
do
sed -i '' 's/--- layout: post //g' $FILE
sed -i '' 's/date.*---//g' $FILE
sed -i '' 's/title: /# /g' $FILE
sed -i '' 's/<!--.*-->//g' $FILE
done