Want to hire me? For availability and scheduling please email info@arcepm.com

26 October 2010

Stupid Programming Tricks #4

Introduction

This is number four in my series of short tricks and tips. 

 

I debated about the utility of this until I spent an hour trying to figure out how to search MaxL scripts with Windows Explorer’s Search function.

 

The fix is easy and oh so useful.

What am I trying to do?

Let’s say I want to find all of the MaxL scripts that use the “spool” command.

 

If I searched all of the .txt files in a given folder, Explorer’s Search function would give me a nice list of files that contain the string “spool” in the file body. 

 

To prove this, I renamed a MaxL file so that it has an extension of .txt.

 

Here are the results:

 

But if I search the same folder for the same file with a .msh extension I get this:

 

Of course, I could:

1)    Find every MaxL script (in my world, they end with a .msh, and yes, that is important) in a given folder, harddrive, computer, etc.

2)    Open up every one of those MaxL scripts and search within for “spool”.

3)    Do an Oedipus Rex and take out my eyes with knitting needles in a completely non-Freudian way because of the despair, ennui, and avoir le cafard that steps one and two engender.

 

But there is a Better Way.  The cockroaches of Sidi-Bel-Abbes will thank me for that one.

Don’t fear the Registry

Go to the Start->Run menu and type regedit.

 

A key is required

If you’ve already changed .msh files in Explorer to open with Notepad or my personal favorite TextPad, this step isn’t necessary as  the main key will exist in the registry.

 

Add a new Key:

 

The Registry Editor will stick this new key at the bottom of the list – don’t worry about the order.

 

Rename the selected text to .msh and hit Enter.

 

Tell Search to look inside .msh files

Add another new key to the .msh key – I guess you could call this a subkey – by right clicking on .msh.

 

Here’s what it looks like:

 

Now give that key a default String value:

 

It is not going to be set by default.

 

Right click on (Default) and select Modify.

 

Now we need to give the Default key a very specific value.  Just copy and paste this into Regedit:

{5e941d80-bf96-11cd-b579-08002b30bfeb}

 

 

After you click on OK, you should see the following:

 

Log off and log back on; rebooting shouldn’t be necessary.

Conclusion

Search now lets you look inside .msh files.

 

Not a big deal, or the world’s best hack, but it sure is a nice way to search for a string within a non-standard file type.  Of course you can extend this technique to .csc, .rep, and .whatever files you need to scan.  Useless 99% of the time, but when you need it, you need it.

 

Happy hacking till next time.

3 comments:

dwelden said...

2 thoughts:
- Where did you get that GUID for the default key? Is that specific to Explorer search functionality, or did you just generate one?

- You do know about DOS command findstr, yes? No registry edits required with that.

Cameron Lackpour said...

>>Where did you get that GUID for the default key? Is that specific to Explorer search functionality, or did you just generate one?

^^^ I just did this specifically for MaxL, but it could be any non-standard extension. See: http://support.microsoft.com/kb/309173

>>You do know about DOS command findstr, yes? No registry edits required with that.

^^^I lurv DOS (or the NT Command shell or whatever it's called) but sometimes a GUI is nice to work in. :)

All kidding aside, I am honored that you read my blog, David.

Are you coming to Kaleidoscope next year? I don' think we've ever met.

Regards,

Cameron Lackpour

Willis said...

If you're finding Windows Explorer to be limiting another option is to make the move to an alternative tool.
I started using xplorer2 last year and haven't looked back.
Think my favourite thing is being able to have 2 folders side by side.