Thursday, August 21, 2008

So the Command-line Continues to Live

I can remember carefully crafting AutoExec.bat and Config.sys files to get certain games and programs to work in ye-olde Dos 5.0 days. Days of the old Dos command which I knew and used much, were: DIR /W /P, CD /D, CD.., DEL, MOVE, COPY, DELTREE, DOSSHELL. I really didn't have much of an idea of what most of the commands in AutoExec. bat or Config.sys did or meant, but if typing "SET SOUND=C:\CREATIVE\CTSND" and "SET BLASTER=A220 I7 D1 T2" would get me sound, or If I was to set the right amount of memory to HIGHMEM I could play Betrayal at Krondor I would mod it.

It is kind of strange how things have progressed in the realm of the Computer. The old Apple2 was command-line, it wasn't until the Macintosh that GUI was to be the new interface and command-line was supposed to be outdated. Microsoft followed suit by trying to eliminate anything DOS like Windows until Windows NT. Anyone remember the days of "There is no more DOS," from Windows 9X days?

But the command-line is back with full force. There is an install mode for Server 2008 where only the minimum complement of Windows gets installed, and it is all command-line. Even Apple has a command-line in their Unix based OS.

Lately I have been finding myself digging into the Command-line more and more, writing batch file after batch file. It started at home when I went searching for a program which would converter .cdr files to .svg; I eventually found one but it was command line, so I had to  come up with a batch file which would recurs a directory converting any compatible vector images to .svg.

Then I decided I wanted to see if I could reduce the footprint of some of the folders on my hard drive, so I went searching and found pngout to compress many types of images to smaller lossless pngs. It even compresses most pngs around 75% of the original size. But again, the free version is a Command-line exe, so I built a script which would recurs a folder and compress the images inside.

As I started using my scripts I discovered that some programs choke on spaces even when quoted, so I searched and searched until I found a batch script which would remove spaces from filenames.

As I learned I found better ways to do some of the tasks, little little known flags which could be set to do useful things like get only a file name minus the extension so I could then change the extension rather than append the new one like I had been doing converting to svg. With this one I then needed to come up with a script which would delete the old files then create the new.

And so it goes with work now as well. Many of the internal tools are command-line driven, even the automation harness. So I have been trying to figure out ways to accomplish rather convoluted tasks all from batch language. It's a fun challenge, and make work more interesting. Now if I could just keep what I learned from writing a script for the next time I need to write something similar, rather than having to go back and look at my old code, I might actually be more productive.

But good times.

No comments: