DEV Community

mafflerbach
mafflerbach

Posted on

Evolving my publishing workflow

After i published my first Article I decided to work on my workflow.
In this article i will expand my bash script.
I want to have all Article on one location but in different subdirectories. This directory is organized like this:

├── content
│   ├── drafts
│   │   └── Evolving my publishing workflow.md
│   ├── ideas
│   └── published
│       └── 20-10-2020 Create a new post via API.md
└── helper.sh
Enter fullscreen mode Exit fullscreen mode

In the drafts directory, i will have all my started article (hopefully only one file at the time).
In ideas, i will collect my articles which have only a title and contains some hints, notes or links for discovery.
In published i will collect all my published Article.

When i published my Article, the file will be moved from the draft directory to the published directory. I don't want to loose the publishing date of the article, so i want to add a date in front of the filename.

To achieve this i add the following lines in my bash script:

# escaping filenames with spaces for the mv command
filePath=$2
#get the current date
date=$(date +%m-%d-%Y)
# grap only the filename
fileName=$(echo "$filePath" | cut -d"/" -f3)
mv "$filePath" "$(pwd)/content/published/$date $fileName"

Enter fullscreen mode Exit fullscreen mode

In the next article i will take look on Front Matter and how to use this in the context of publishing on dev.to.

Top comments (0)