Why doesn’t DOS have a Touch command?

I had need recently of a touch command in DOS and found there wasn’t one, so I went away and made one. I’ve put it in the projects directory so you guys can get either the executable or the project files of how I built it.

I’m repeating here what I wrote in the projects page since it’s just easier that way.

Recently I was experimenting with the Videora Iphone video convertor – found here. and found it had a nifty feature where I could point it at a directory, copy video files into that directory and it would automatically pick them up and start converting them. Very useful given that while this works well, when it is working it tends to eat my PC completely. Once it starts a convert trying to set up more in the queue is an exercise in frustration since the front end UI script it uses is flash and is delivered via the web to the app and it’s just extremely tedious and slow (there is no group feed mechanism apart from this file directory thing).

Anyway, the problem I had is that occasionally I’d need to stop the conversion in progress because I needed the PC for something but upon restarting the app would loose the files it had in it’s queue. The only way to get it to pick those files up again was to recopy them into the directory, which is bogus. What I needed was a touch function like Unix and Linux has – that way I could just update the last modified times on the files and viola, Videora would pick them up again. Trouble is, DOS doesn’t have a touch function. It’s bogus and phoney (as some old friends would say) but that’s the reality.

However, bouyed by what my old friend Clint Hocking once said to me – to whit “You’re a programmer – go write it” I thought, ok, lets do it. C# is pretty easy to get to grips with so I spent a couple of hours whipping this up. It’s basic but it works. It’ll handle paths at the front of the file definition, wild cards and so on. It has a verbose mode and a recusive mode so you can go down through directories.

To use is simplicity itself. At the command prompt type c:/>touch blah.jpg or c:/touch dir_name/blah.jpg

This will touch the file blah.jpg.

The app will also handle c:/>touch blah*.* for wildcards, or c:/>touch blah??.*

To get it to go down directories use the /r paramenter E.g. c:/touch dir_name /r – note you can use wildcards in directory names too E.g. c:/touch dir_name* /r although note the wildcarding does not go down the directory structures – it only applies at the top level. If there are both files AND a directory who’s name falls into the wildcarding, all get touched.

To get more verbose reporting you can use the /v parameter E.g. c:/touch dir_name /r /v

Lastly, when touched a files creation date and last modified date are updated the current time.

So I thought I’d hand this out – it’s FREE,- Download HERE – this is the release executable in zip form. Just unzip and dump the resultant executable in your windows/system32 directory (first virus scanning it – there are no trojans in here but be safe anyway) and it’ll be available from any command line prompt. Of course you will need the .Net framework installed on your system for it to work (any version is fine) but since that’s part of the MS patching facility I’m sure you all will anyway.

And because I’m nice I’m handing out the C# source code to it too. This is a command line C# application – the solution is in there too. This will show you how to use dirinfo and functions of that ilk.

It requires MSN Visual Studio 2003 .net V7.1 (this project Won’t Load in version 6).

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>