During this pandemic, we’ve all been forced to adapt to remote learning and working from home. If you’re like me and always looking for ways to work more efficiently, this article is for you.
For students, daily assignments have become the norm. While submission methods may vary, creating PDFs is a common requirement. This is especially true for engineering students who need to submit programming assignments. The typical workflow involves coding 10-20 problems, copying each solution into a Word document, and then converting it to PDF. While this may seem manageable at first, doing it multiple times daily quickly becomes tedious.
As programmers, we should leverage our skills to simplify repetitive tasks. With this in mind, I’ve created a simple bash script to automate this process.
Let’s break down the key components of the script:
- To ensure flexibility, the script accepts three inputs:
- The directory containing the code files
- The desired output filename
- The file extension to process (making it work with any programming language)
-
The script needs to iterate through all files with the specified extension in the given directory.
-
It then writes each code file to a temporary document, prefixing each solution with a number for organization.
- Finally, it converts the temporary file to PDF and cleans up by removing the temporary file.
Here’s the script that handles all of these tasks automatically:
Well I hope this was helpful for all the lazy folks out there. Stay safe, stay indoors and be lazy.