How to Save a File with Notepad Without the .txt Extension

and how to fix the problem for files already saved


How to Save a File with Notepad Without the TXT Extension

by Christopher Heng, thesitewizard.com

On occasion, I get questions like "I created a file called xyz.php or xyz.html using Notepad, and after uploading it to my website and testing it with my browser, I get a 404 File Not Found error. What do I do?" Another variant of this question is "I tried to save my file as xyz.pl but when I uploaded it to my website, I can only find xyz.pl.txt. How do I get the file to be xyz.pl?" This brief article explains how you can solve this type of problem.

Ruling Out the Obvious: Make Sure You Uploaded to the Right Place

If it's a "File Not Found" error that you have, before we proceed to fixing the problems created by Notepad, it is important to first eliminate the possibility that you uploaded the file to the wrong directory.

Simply connecting to your website via your FTP program and uploading the file into the directory you first connect to is probably going to place your file in the wrong location.

Web servers are configured so that they serve files only from certain locations. They don't, for example, display your email from your mail folders for all to see. Typically, on your web hosting account, you have to upload your files into a directory called "www" or "public_html". Find out from your web host where you need to upload your files so that they will be displayed correctly.

If you have checked and know for sure that you have not committed this error, move on to the next section.

How to Fix the Problem Created by Notepad

The other possible reason for the error is Notepad. Notepad, up to the current version, has the practice of adding a ".txt" extension to your files even when you don't specify it. So if you give your file a name of "xyz.html", Notepad will change the name to "xyz.html.txt" without informing you. Compounding this problem is Windows Explorer's policy of not telling you the full filename of your files. Hence if you use Explorer to check the file, it will only show "xyz.html".

If you have already saved your file, the best way to solve this is to first force Explorer to always show you the file extension, and then change the filename to the correct one. This is good practice anyway, since always being able to see the full filename probably improves your system's security — you'll be less likely to be tricked by all those scams asking you to click a file that appears to be a picture but is actually a program.

On Windows, click the Start menu, and type "folder options" (without the quotes), and click the "Folder Options" line that appears near the top of the Start menu. Click the "View" tab in the dialog box that appears. Look for a setting "Hide file extensions for known file types" and uncheck the box beside it to disable it. Then click the "OK" button at the bottom of the dialog box. (If your version of Windows does not seem to behave as I describe here, or the steps are too vague, see the more detailed instructions in my full tutorial on this.)

You should now be able to see your file as its true name, be it "xyz.php.txt" or "xyz.html.txt" or whatever. Now click once on the filename. Explorer will now allow you to change the filename. If this is not true, select the filename and hit the F2 key on the keyboard. Delete the ".txt" extension, leaving the filename as "xyz.php" (without the quotes) or "xyz.html". Make sure there are no trailing dots or spaces — that is, make sure the filename is really "xyz.php" and not "xyz.php." with a trailing dot or the like.

When you hit the ENTER key, Windows will issue a warning about the dangers of changing filenames. Allow the name change to take place.

While this fixes the problem, read the next section to find out how you can avoid having to repeatedly do this in future, every time you use Notepad.

How to Avoid the Automatic ".txt" Extension Problem in Notepad in Future

When you want to force Notepad to save, say, "xyz.php" without a ".txt" extension, save it as "xyz.php", including the quotation marks, in the Save As dialog box. When you include the quotes, Notepad will save the file with the xyz.php name literally, without adding any additional extensions.

Alternatively, you may prefer to get a better text editor. There are numerous free ones on the Free Programmer's Text Editors page. Don't be intimidated about the "programmer's editor" bit. Despite its grandiose name, programmers' editors are simple text editors with additional features to make it easier to work with than Notepad.

Copyright © 2007-2020 by Christopher Heng. All rights reserved.
Get more free tips and articles like this, on web design, promotion, revenue and scripting, from https://www.thesitewizard.com/.

thesitewizard™ News Feed (RSS Site Feed)  Subscribe to thesitewizard.com newsfeed

Do you find this article useful? You can learn of new articles and scripts that are published on thesitewizard.com by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at https://www.thesitewizard.com/thesitewizard.xml. You can read more about how to subscribe to RSS site feeds from my RSS FAQ.

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.

Related Pages

New Articles

How to Link to This Page

It will appear on your page as:

How to Save a File with Notepad Without the TXT Extension





Home
Donate
Contact
Link to Us
No Spam Policy
Privacy Policy
Topics
Site Map

Getting Started
Web Design
Search Engines
Revenue Making
Domains
Web Hosting
Blogging
JavaScripts
PHP
Perl / CGI
HTML
CSS
.htaccess / Apache
Newsletters
General
Seasonal
Reviews
FAQs
Wizards

 

 
Free webmasters and programmers resources, scripts and tutorials
 
HowtoHaven.com: Free How-To Guides
 
Site Design Tips at thesitewizard.com
Find this site useful?
Please link to us.