Associate Any File with Notepad in Five Seconds

In my article, Associate Extensionless Files with Notepad, I explain how to navigate the labyrinthine maze of Windows dialogue menus to assign Microsoft’s Notepad text editor as the opening application for files without extensions. In this post, I’ll show you how to associate any file type with any program (including Notepad) in less than five seconds.

Ready? Don’t blink, you’ll miss it.. ;)

Modify any file extension association in five seconds

Open the Windows command prompt and enter the following command:

assoc .extension=fileType

It’s that easy. What is happening here? Let’s break it down, just for fun:

  • assoc — Windows file-association command
  • .extension — the extension of the file for which you would like to associate
  • fileType — the type of file that you would like to associate with your extension

Some amazing and useful facts about the assoc function:

  • Type the command “assoc” without parameters to display a list of current file extensions
  • Any fileType value shown in the aforementioned list of file extensions may be used for your files
  • If the assoc command is run with only the file-extension parameter, the function will return the current file association for that file extension
  • If nothing is specified for the fileType, the assoc function will delete the association for the given file extension
  • To learn more about the assoc function, enter the following command via the Windows command prompt: assoc /?

Here are some common fileTypes that may be useful (for an entire list, enter the “assoc” command without parameters) — you know, because you may want to open your files in something other than Notepad (although I don’t see why you would):

  • wrifile — opens in WordPad
  • Word.RTF.8 — opens in MS Word
  • Word.Document.8 — opens in MS Word
  • htmlfile — opens in your default browser

Sound good? Let’s check out a few examples.

Associate extensionless files with Notepad

Here’s how to associate extensionless files with Notepad in one swift stroke:

assoc .=txtfile

And done. Testing this method is easy because the association command works on any file. To check it, create a new file named something without an extension (e.g., “pancakes”). You will see the default Windows icon designating an unknown file type. Now run the command given above. Presto change-o rearrange-o! Your new extensionless file is now magically associated with Notepad. Go ahead, double-click on it and watch it open! Amazing :)

Associate other file types

Just because I am having so much fun with this little tutorial, let’s check out a few more examples of files that are common to us web-developer types.

.xml files
For some reason, Photoshop insists on claiming all XML files on my system. This is ridiculous, of course, but the situation is now resolved thanks to the following command:

assoc .xml=txtfile

Now, rather than launching Photoshop when I click open an XML file, the file appears instantly and ready-to-edit in Notepad. Ahhh, what a relief! :)

Raw access log files
As discussed in my article on Harvesting cPanel Raw Access Logs, checking your site’s access logs involves dealing with files that are named after your domain. For example, the access logs for Perishable Press are named “perishablepress.com”. This is fine for the server, but sadly Windows is not familiar with extensions like, “.com”, “.net”, “.org” and so on. So, rather than tediously renaming my log files, I run the following commands and call it done:

assoc .com=txtfile
assoc .net=txtfile
assoc .org=txtfile

.htaccess files
This five-second technique is perfect for HTAccess files. Off the truck, Windows can’t handle nameless files with the crazy .htaccess extension. Fortunately, we can teach Bill’s beast a little respect:

assoc .htaccess=txtfile

[ Windows Command Prompt ]
Pow! In your face, Microsoft!!! ;)

Dropping Skullz

As mentioned in the dazzling intro, this method works great for associating any type of file (i.e., any file extension) with Notepad. For web developers and designers working with the Windows operating system, this simple command-line trick is immensely helpful when dealing with the wide variety of unusual file types commonly associated with server configuration and management. Here are a few examples of files types that Windows just can’t handle without explicit instruction:

  • .htaccess
  • .ftpquota
  • mutex.lock
  • domain.tld
  • mime.types
  • httpd.conf
  • cache (no extension)

Now, rather than wasting time fighting your way through a right-click and two or three dialogue boxes every time you need to open an unknown file type in Notepad, take a few seconds to execute a simple Windows command and forget about it. Nothing could be easier!

Thank you to Ian Flournoy for sharing this incredibly useful technique!