Convert Textile files to Markdown with a shell script

Created: January 18, 2019 09:21 | Updated: January 18, 2019 09:21
Tags: Linux, Shell Scripting

Oh no! You have a ton of textile files which look like they are going the way of Betamax, and you wish that they were Markdown instead! Shell scripting to the rescue!

Install pandoc

sudo apt install pandoc

Navigate to your directory where the files are in the terminal of your choice and create your script file.

'''bash cd your/file/directory touch converter.sh chmod +x converter.sh gedit converter.sh '''

Get a list of your filenames

find -name "*.textile"

And make your shell script using this as a template:

#!/bin/bash
#converter.sh

filenames=(file1 file2 file3 file4)

for i in ${filenames[@]}; do
        pandoc ${i}.textile -o ${i}.markdown

done

Save and run your converter

./converter.sh

Move your old textile files (I'm going to call them posts) into an old_posts directory

mkdir old_posts
mv *.textile old_posts

And you are done!

Written by Alan Vardy. Let me know how I can make this better!