Trim Leading and Trailing Whitespace from a String

Posted On Mon, 30 Sep 2013

Filed under Batch
Tags: , , , , , ,

Comments Dropped leave a response

Hello All! :-)

I’m back after a long hiatus with a Batch file that trims leading and trailing whitespace from a string. The program won’t choke on “poison characters” and doesn’t care about the state of delayed expansion. At last, something other people may find useful! ;-)

To achieve this, however, I’ve had to employ several advanced Batch programming techniques. The code may be difficult for beginners to follow, but I’ve tried to explain how the program works and I’ve included links to fuller explanations of some of the techniques used.

continue reading »

Renovations Underway

Posted On Mon, 1 Jul 2013

Filed under Announcements
Tags: , , ,

Comments Dropped leave a response

Hello All!

Apologies for not posting in a while.

I’ve come to the realisation that my blog needs an overhaul. One or two posts have become obsolete, a few links need updating, and my Batch programs need rewriting.

Stay tuned for updates!

Weakest Link Australia

Alleged transcript from TV gameshow Weakest Link Australia which ran from 2001 to ’02. Extremely doubtful if this actually happened, but if you’ve ever seen the show you’ll understand why someone might react in the way the contestant did here.

continue reading »

A More Robust Line Counter

Posted On Thu, 23 May 2013

Filed under Batch
Tags: , , , , ,

Comments Dropped 2 responses

In a previous post, I talked about how to count the number of lines in a text file. I explained the technique of piping the output from type file.txt into find /c /v "" and wrapping the whole thing inside a for /f loop to store the result in a variable. A simple and effective solution to a common Batch programming task. :-)

Too bad it doesn’t work…

continue reading »

Links for Irish VIPs

Below is a small collection of links of interest to blind or visually impaired people in Ireland. Please come back from time to time to check for updates.

continue reading »

Scan Text Files for Control Characters

Posted On Tue, 16 Apr 2013

Filed under Batch
Tags: , , ,

Comments Dropped leave a response

A large part of programming in Batch is taken up with processing text files. By “text file”, I mean a plain text file with Windows line endings. And “plain text” means no nasty control characters such as Control-Z or the infamous Null Character.

For example, the former is used by copy /a and type as the end-of-file marker, while set and echo interpret the latter as the end of input.

So it’s always a good idea to scan any text files of unknown origin for these troublesome characters before doing anything else. Which is why I wrote the ctrlscan.cmd program described below…

continue reading »

Accessibility of Google Search Result Details Buttons

Let’s face it: when it comes to search engines, Google is the standard against which all others are measured. But is Google perfect? Is there no room for improvement?

If you’re like me, and you use a screen reader such as JAWS or NVDA, I’m guessing the answer to both questions is a resounding “No!”

continue reading »

SMS to Email Gateway

Imagine you’re in the middle of nowhere with no WiFi or mobile broadband. You need to send someone a short email message, but all you have is an ancient mobile phone that can only do voice calls and texts. What do you do?

continue reading »

Flowerpot Faux Pas

A class of schoolkids were given a project to decorate a flowerpot they could take home and show off to their parents. They wanted a plant that was easy to take care of, so it was decided to use cactuses.

continue reading »

Generate Any Control Character

ASCII has 33 control characters. Many of them are defunct or are used for purposes for which they were not originally intended. Most of them are unprintable and some can cause problems if not filtered out of input. All the same, a handful of these characters have proven to be indispensible when it comes to performing certain tasks in Batch.

In this post, I’ll show you commonly-used techniques for generating specific control characters, as well as two lesser-known methods for storing almost any control character in a variable. But finding uses for them is an entirely different matter. One which will be covered in an upcoming post.

continue reading »

DIY Slideshows on WordPress.com

I use a screen reader called JAWS (and sometimes NVDA) to browse the web and for updating my blog. It does a pretty good job of most things. But it can’t cope with WP’s visual editor. One consequence of which is that I can’t create image galleries or slideshows—at least, not by conventional means.

This post is based on lessons learnt from putting together a selection of my favourite viral images and outlines an accessible, do-it-yourself alternative to WP’s proprietary method for creating slideshows.

continue reading »

DIY Code Blocks on Posterous

Posted On Thu, 10 Jan 2013

Filed under Blogging
Tags: , , , , ,

Comments Dropped leave a response

The following first appeared on my old blog on Posterous in February, 2012. I moved it here because I’m afraid they’re going to pull the plug on Posterous any day now.

I realise this topic is mostly of academic interest these days, but I decided to archive an updated version of the post for posterity. And the fact that I put a lot of work into it, dammit! :-D

continue reading »

The Funniest Viral Images Ever?

This is a follow-up to my post on the Funniest Viral Emails Ever? This time it’s the turn of viral images. You’ve probably seen them all before, but classics bear repeating!

continue reading »

A Selection of Christmas Links

Please find below a small selection of virtual Christmas gifts from my big bag of links. I hope you enjoy them and that you and yours have a Merry Christmas and a Happy New Year!

continue reading »

Copy a Long Line from a Text File and Save It to a New File

This is a follow-up to my recent post on how to store the nth line of a text file in a variable. The solution given won’t work for extremely long lines because the line requested by the user is stored in a variable and variables in Batch can only hold up to 8191 characters.

If you need to select an extremely long line from a file and save it to a new file, there is a workaround. But it ain’t pretty, or efficient. It involves more, findstr, and a whole lot of temporary files. :twisted:

continue reading »

Average Speed Over Both Journeys

This question is sometimes asked on the GMAT exam, allegedly.

A woman drives to work every morning at an average speed of 30kmph. In the evening, she drives home the same distance at an average speed of 40kmph. What is her average speed over both journeys?

HINT: The answer isn't 35kmph!

Read the rest of this post »

For Sale: (Slightly) Used Car

Posted On Fri, 23 Nov 2012

Filed under Humour
Tags: , ,

Comments Dropped leave a response

1985 Blue Volkswagen Golf

Read the rest of this post »

Store Nth Line of a Text File in a Variable

Posted On Sat, 10 Nov 2012

Filed under Batch
Tags: , , ,

Comments Dropped leave a response

This question crops up from time to time: “How do I save a line from a file into a variable?” It seems like a perfectly reasonable question to ask. You might think the answer is equally as straightforward. Until you try to write a Batch program to do it, that is…

Read the rest of this post »

The Funniest Viral Emails Ever?

Long before Facebook, Twitter, and YouTube, back when AltaVista provided the search results and Netscape Navigator was the must-have browser, people would send each other jokes by email, or “viral emails” as they became known.

Someone working for a large company might receive a viral email from a colleague which he would then forward to his family and friends. And they'd send it to all their contacts, and so on, and so on. By the time the message arrived in your inbox, it would be encrusted with a dozen > symbols in the left margin and buried under a tangled spaghetti of header lines containing the email addresses of literally hundreds of people you'd never heard of.

Which added to the experience somehow. You felt you were “in on the joke” with all those other people from around the world.

The quality varied enormously, but some of them were genuinely funny and have stood the test of time. I've put together a selection of links to what I think are some of the best viral emails ever. If you've read some of them before, it's because they're classics! Wherever possible, I've linked to the original source.

Read the rest of this post »

Convert Newlines from Windows to Unix

Posted On Wed, 24 Oct 2012

Filed under Batch
Tags: , , , ,

Comments Dropped leave a response

16-Apr-2013: Updated source code. Rewrite of post.

Everybody knows the old trick of converting a text file with Unix newlines (LF) to Windows line-endings (CR+LF):

more unix.txt > win.txt

(Note that more will wait for a keypress after scrolling 65,534 lines, even if output is redirected to a pipe or file.) But converting from Windows to Unix is a far more complicated affair. After searching failed to find any straightforward Batch solutions—apart from this meandering thread on DosTips—I cranked out win2unix.cmd as outlined below.

continue reading »

Next Page »