Wednesday, 29 February 2012

Lower casing variables in DOS

Occasionally, I will need to use MS-DOS in my role at work. MS-DOS is one of the scripting languages to use while using Microsoft Windows operating system.

One of the problems with MS-DOS is that it is case-insensitive. MS-DOS does not distinguish the difference between upper case or lower case when using it. While this may not cause problems most circumstances while using Windows, it may potentially cause problems when interacting with other systems or programs.

I have used the following snippet of code to convert the %computername% variable, which was set as upper case to lower case. The result will be stored as %mycomputername%

echo>%computername%
dir /b/l %computername%>lower.tmp
set /p mycomputername=<lower.tmp
del lower.tmp
del %computername%


This snippet works by creating an empty file based on the variable that is in upper case. Then a directory listing is made, with the appropriate flags to list the output in lower case, and the output of this is stored in a file called lower.tmp. Then the contents of that file is read into the new variable. Finally the two temporary files are deleted.

I would have thought it would have been easier than that.

2 comments:

  1. I'm really, really fascinated to determine exactly what celine outlet is going to do throughout the woman's period from Celine. We cherished the actual Philo many years from Chloe; in the end, these people do spawn a few fairly renowned purses (the actual Paddington, anybody? )#). Celine created a few celine bag We loved a great deal final period, that was a pleasant turn-around using their usually staid however dull cost. I’m getting a few difficulty determining in the event that this particular tote is actually through celine handbags’s final selection prior to Philo or even their own very first selection along with the woman's, however in either case, the actual Celine Dimitri Python Hobo is actually an additional part of the best path.
    I'm really, really fascinated to determine exactly what [url=http://www.celinebagcheap.com/]celine outlet[/url] will do during her tenure at Celine. I loved the Philo years at Chloe; after all, they did spawn some pretty legendary handbags (the Paddington, anyone?). Celine made some [url=http://www.celinebagcheap.com/]celine bag[/url] I liked quite a bit last season, which was a nice turnaround from their normally staid but bland fare. I’m having some trouble figuring out if this bag is from [url=http://www.celinebagcheap.com/]celine handbags[/url]’s last collection before Philo or their first collection with her, but either way, the Celine Dimitri Python Hobo is another step in the right direction.

    ReplyDelete
  2. I do NOT endorse the on-line store in the comment above, as I have never done any deals with them. Be careful in any purchases you make with them - but I welcome any and all comments about them.

    ReplyDelete