Cool@Hoole

The Other Black Art

This entry was posted in Software, Work Flow and tagged . Bookmark the permalink.

Since we are two days away from Valentine’s Day, you’re probably expecting a blog about love and romance. Close, this blog is about the automation of repetitive tasks through the use of a scripting language, and who doesn’t love that?

Perhaps you find yourself working on a task that seems mindlessly repetitive. Maybe as you drift into a boredom-induced coma, you think to yourself that surely such a task is better suited for a tireless machine to slave away on, and not an easily bored human. I recently had a similar inner monologue, but instead of waiting for the age of reasonably affordable robots, I decided to use a bit of wizardry to make my computer complete this task for me. That is to say, I wrote a script.

Scripting languages are wonderful things, and share a lot in common with their two ancestors, genies and magic. In layman’s terms, scripts do stuff. Computer stuff. Stuff you don’t want to do. Any computer-based task which can be handled by a human (and doesn’t require any sort of creativity) can conceivably be handled by a script. Bill Gates is quoted as saying:

The first rule of any technology used in a business is that automation applied to an efficient operation will magnify the efficiency.

Scripts are especially well suited for the long, mindlessly repetitive tasks that leave most of us humans cringing. These tasks involve a set of actions controlled by a specific set of rules, like say only moving files with certain filenames, or changing one specific file type to another. These actions and rules need to be explained to the computer in a language the computer understands. Computers are basically dumb; they can only count to 1. You could write your programs in zeros and ones if you wanted to (I don’t) or you could use a higher language that interprets your commands into zeros and ones for you.

I am currently learning two scripting languages, Perl and Python (In my spare time I’m also trying to pick up a little AHK and a micro-controller language, but that’s neither here nor there). Of these, Perl is quickly becoming my favorite for a number of reasons. I like the way variables and arrays are easily distinguishable by their leading “$” and “@” signs respectively. I enjoy not having to call variables, and of course there’s CPAN (an online database of pre-written code, which I’m sure will prove helpful in the future). On the other hand, Python doesn’t require the trailing semi-colon or curly brackets which is nice, though it’s really just a lateral move when you consider Python’s force indent policy. In the end, it doesn’t matter what scripting language you choose, just choose one and learn it. You don’t have to master every aspect of the language in order to write useful scripts; you’ll be surprised what you can accomplish with just some basic working knowledge.

The task I wanted to automate involved moving files from one directory to another, while creating unique folder names based on the first 21 characters of the file names, and then moving said files into said folders. Not a particularly difficult task when there are just a few files, but when you would need to routinely accomplish this for a large quantity of files it becomes time consuming. Thankfully, it’s also immanently script-able. So I wrote a script in a Perl, tested it, and when it was fully functional made it available to the rest of my team. Another co-worker, who happens to also possess programming know-how, wrote a graphic user interface for my script which added to the script’s usability. I went back in and changed the color scheme to his interface which added to the script’s prettiness. But the important part is, my script will save me and my co-workers a little time every day, and that’s time and energy that can be put towards other tasks. Tasks better suited for us humans.

-Austin Dixon, Digitization Technologist | Hoole Library

This entry was posted in Software, Work Flow and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *