Automate boring tasks with batch scripting

Shubham Metkar
2 min readFeb 17, 2023

--

Photo by Arget on Unsplash

This article focuses on how to automate repetitive, tedious tasks while setting up with project you are regularly going to work on.
For the sake of simplicity we’re going to assume windows OS but the implementation is not limited to any specific OS.

Being a full stack web developer our most of the projects have dedicated separate folders of frontend & backend where in respective files/folders resides like this👇🏻:

project/
├─ frontend-folder/
├─ backend-folder/

So while I used to start working on project tasks I always faced this issue of going into each directory path➡ open CMD ➡ run command to set local server up. Then opening VS code or any code other editor to start working.

To automate this I narrowed down to two solutions for this:

  • One with using an npm package concurrently but in my opinion this is least approachable solution as this requires to install a new npm package then changing your start/dev scripts in package.json. Why it’s not recommended because for personal projects it’s fine but while working on organization projects you’re definitely not allowed to tweak this way
  • Now comes the second solution which we are going to discuss on:

We will now write a very basic windows batch script.
So what’s batch script in layman terms:

Batch Scripting consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file

More detailed explanation on this is something I’ll leave up-to you as it is beyond the scope of this article.
So let’s right away jump into the code ➡

Let’s understand this tiny piece of code
- @echo off : This prevents the prompt and contents of the batch file from being displayed, so that only the output is visible. The @ makes the output of the echo off command hidden as well.
- Next we’re starting command prompt & assigning your frontend folder path and running the command to start local server.
- Now same process for backend part.
- At last opening VS code.

What’s the process:
➡ Create a simple text file paste this piece of code and save this file with a .batextension. Just double click the file to run everything.
But where to put this file?
➡ Anywhere on your PC.

So this is it!
With a simple double-click on this file we’re automating 3 manual tasks simultaneously.
Is this going to bring a world-changing impact? …. Definitely not.
And that being said this meme never gets old XDD, happy weekend!!

--

--