Ask Leo! by Leo A. Notenboom

What does "If you change a file name extension, the file may become unusable" mean?

Search First! Then browse: Categories | Full Archive | By Date | Newsletter

Home » Windows » Windows Oddities

Summary: Filename extensions are important pieces of information that Windows uses to determine what a file contains. Change it, and you could lose access.

Recently, been having a problem when I try to rename a picture or an icon, the following message appears: "If you change a file name extension, the file may become unusable". I have lost pictures when I went ahead and ignored the message. Why am I suddenly having this problem?

I don't know why you're suddenly having the problem, but I do know what the problem is.

You actually haven't lost your pictures - you've just removed the information that tells Windows what to do with them.

First, we need to understand how filenames are constructed. There are actually four parts to a full file path:

C:/path/basename.ext

Where:

  • C: is the drive on which the file resides. (This can also be \\server\share for shared files located on a local area network)

  • /path/ is the path of folders and subfolders underneath which the file resides

  • basename is the base name of the file . This is probably what you think of as "the name", in that it's the part you choose to name or describe the file.

  • .ext is the extension. This is the part that tells Windows what kind of file it is.

"I'm going to assume you're renaming your file using Windows Explorer, since that's where it's very easy to run into the problem you're seeing."

The "filename" typically refers to the base name plus extension or basename.ext.

I'm going to assume you're renaming your file using Windows Explorer, since that's where it's very easy to run into the problem you're seeing.

Even though almost all files have the extensions, Windows Explorer does not display them by default. This is a huge mistake in my opinion, but it is what it is.

Here's what I mean:

Windows Explorer Thumbnail View

This is Windows Explorer in Thumbnail view on a folder of some pictures I have. Note how the filenames don't show any extensions.

In Windows Explorer, click on the Tools menu, Folder Options menu item, and then the View tab:

Windows Explorer Folder Options highlighting the 'Hide extensions for known file types' option

Uncheck the "Hide extensions for known file types" option. Now we look at our files again:

Windows Explorer Thumbnail View - Including filename extensions

As you can see, each filename's extension is now visible: these are ".JPG" and ".NEF" files.

Now, I'm going to click on one of the images and press F2 to rename the file:

Thumbnail after pressing F2 to rename.

If I start to type a new filename, it overwrites the extension as well:

Thumbnail during rename

And sure enough, once I press Enter, I get this warning:

Windows Explorer File Rename Warning

The problem? The ".jpg" is missing. Windows knows what a "_DSC5278.JPG" file is, it's a jpeg image, or photo. But it has no idea what a "Horse" file is ... the extension has been lost and Windows has no idea what to do with that file. It doesn't even know how to show you a thumbnail:

Windows Explorer thumbnail of a file with no extension

Regardless of the path that you took to rename your file, that's the problem - the filename's extension is missing or incorrect.

The solution, of course, is to include or preserve the extension when you rename the file:

Windows Explorer thumbnail of a .jpg file

Simply by including the ".jpg" when I renamed the file, Windows understanding of what that file is has been preserved.

A couple of notes:

  • I strongly recommend not hiding extensions in Windows Explorer, as demonstrated above. Hiding extensions can actually allow malware to trick you into thinking they're something that they're not. For example, with extensions hidden "horse.jpg.exe" would display as "horse.jpg". You might think it's a picture, but it's not - double clicking on it could launch a dangerous piece of malware.

  • In that same vein, be careful to know what it is your acting on - it's not that uncommon to see pictures named "horse.jpg.jpg" because people didn't realize extensions were hidden. It's typically benign, but it can be confusing. Again, not hiding extensions solves this problem.

  • You'll note that ".JPG" and ".jpg" were treated the same way. In general extensions are case insensitive - .jpg is the same as .JPG - in Windows (though they are typically case sensitive - .jpg is not the same as .JPG - when uploaded to web sites). Best to pick one approach and stick with it.

  • You cannot change a file's type simply by renaming it. For example, you can not change a jpg file to a png file just by changing the extension to ".png". It may be called a ".png", but it's still a jpeg file on the inside.

Related:

Helpful? Get new articles weekly by email in my FREE newsletter!

Your Name:
Your Email:


Why Subscribe?

Article C3833 - August 8, 2009

Recent Comments
9 Comments

The idea is obviously to make file management idiot-proof, but it really makes a lot of sense to learn how to recognise and use file extensions. I automatically unhide them on Windows installations. Vista took a step in the right direction by only highlighting the actual file name when renaming.

Posted by: snickers at August 11, 2009 8:39 AM

I found this article to be very informative . It has given me very good information.I had no idea how to make the changes you have just shown.

Posted by: claude johnston at August 11, 2009 11:33 AM

I have file extensions showing, as it may show up a rogue .exe masquerading as something else.

Posted by: David at August 11, 2009 1:27 PM

I use this site when I run across an extension that I don't know which program it belongs to. It also helps when checking the default file associations, especially after a new piece of software starts changing those associations. There are other sites out there that do the same thing, but this one suits me the best.

http://filext.com/index.php

R

Posted by: R at August 11, 2009 2:40 PM

Finally you have solved my identical problem which I have been having with file name changing and receiving the same dialog box. Thanks ever so much.

Posted by: Paul at August 11, 2009 7:18 PM

For this and the related 3 articles I will buy you a coffee.
The articles solve many problems I have had over time and still get once in a while.
Thanks again Leo

Posted by: Chris at August 11, 2009 8:05 PM

Thanks for that info... I learned something today! Now why those little pesky things pops up makes sense! I had no idea how to fix it.

Posted by: Debbie at August 12, 2009 6:01 AM

Would this be a backdoor way to make a file inaccessible to someone else? Say I have a journal I keep in Word but don't want anyone else to read it. Can I simply to to Explorer after saving it, take off the .doc extension, then, when I want to open it, go to Explorer, edit the filename to add the .doc? Would this hurt the file any after doing it several times?

It won't hurt the file, but it could be discovered if someone went looking. "Security by Obscurity" is rarely a truly secure approach. If it's important, encrypt it.
Leo
18-Aug-2009

Posted by: Alexis Corelis at August 17, 2009 8:40 AM

@Alexis Corelis -- For a personal journal? ...Maybe -- and that's assuming whoever wanted to read it had to find it first and was not particularly computer-savvy.

But for anything even slightly more important than that, changing the file extension is more likely to be completely ineffective.

Even on Windows, it's trivial to detect the type of most commonly-encountered files even if the extension part of their filename is missing or corrupted: all one has to do is open the file and try to recognize what's in it -- in many cases, this is as simple as reading the first couple of characters. For instance, an .exe file (or a .dll, for that matter) can be recognized from its first two characters: "MZ". A .zip file will start with "PK". Linux ELF binaries all start with the characters "ELF". All of these are part of the standard that defines how these files are created and used, which means there are very well-known signs to watch for when trying to find out what type a file is.

The main reason against detecting a file type this way (and thus making the extension irrelevant as a way of actually determining a file type) is that opening, say, 1,000 files in the same directory in order to read the first few characters in them is a slow process. Nonetheless, I'm vaguely certain Linuxes (and probably Mac OS X) have been doing it for a while now. On my Xubuntu, I can rename "my-pic.png" to "hahaha" and it still gets properly detected as a PNG image and opens correctly if I double-click it. Note that this is something I can do without any work on my behalf at all -- it's part of the OS itself. And I'm certain the same capability could be built into Windows, at some potential (small) cost in speed.

To summarize: an extension is just part of a file name, which is why it's not likely to be particularly trusted as anything but a first guess at what might be inside. As such, renaming a file to hide its extension does not make it any more secure than moving it into the recycle bin and moving it back out when you want to work on it.

If you have any type of data you truly consider sensitive, use some kind of encryption to hide it behind a password or passphrase only you know. Leo has been recommending TrueCrypt for a good long while, and with good reason.

Posted by: Octav at August 17, 2009 9:27 AM

Post a comment on "What does "If you change a file name extension, the file may become unusable" mean?":






(Email Address will not be published.)

Remember Me?

By popular demand...
my tip jar
Cuppa Joe
Buy Leo a Latte!

(you may use HTML tags for style)

RSS feed Subscribe to the RSS Feed specifically for comments on this article.

Before commenting, please...

  • Read the article at the top of this page. If your comment shows you didn't, it'll be deleted and ignored.

  • Comment only on this article. Use the Google search box at the top of the page if you have a question about something else.

  • Don't include personal information in the comment. No email addresses. No phone numbers. No physical addresses.

  • Don't spam. Excessive links to unrelated sites within a comment or across multiple comments will cause all such comments to be removed.

  • Don't ask me to recover lost passwords or hacked accounts. I can't, and those comments will be deleted.

  • I can't respond to every comment. And I can't vouch for the accuracy of others who do.

Please wait. Your comment is being processed ...


Question? Ask Leo!