4

In Windows there's an option to view extensions for known file types. When I enable that option I see all the files with their respective extension; for example an mp3 music file is: name.mp3

If I rename it to name.txt, then the default program to view the file would be text editor.

How do I rename a file's extension in Ubuntu?

I want to create the file: autorun.inf

In Windows I just create a new text document .txt (enable the view of extensions) and rename it to .inf, but in Ubuntu that doesn't work.

So how can I do that in Ubuntu?

2 Answers 2

6

Forget about the concept of "file extensions" that thing is completely made up and useless. For example somebody could rename a music file on your system to garbage.gbr and since windows interprets extensions literally as file types it wouldn't even know that the file was a music file.

In Ubuntu on the other hand, you can name a file whatever you wish. You don't even have to choose an extension if you don't feel like it. Ubuntu will read the MIME type of the file and understand what type it is. Based on the file type it will associate it to the appropriate program to open it. You still have all the control you need. You can change the default program associated with a MIME type in several ways.

enter image description here

To change default program association of a file type, just right click on a file with that type and choose Properties and go to Open With tab.

Now that being said, I should mention that extensions are not completely useless in Ubuntu. They still provide a standard way to tag a file for easy identification of its type -- but they don't set the file type. The only exception to this is when saving a file in some applications that support saving in several different formats. When you provide a file name in those application it can read the extension you provided and based on that decides how to create and save your new file with the correct mime type. For example if you open a JPEG file in GIMP and then choose save as ... and enter image.png, GIMP opens the PNG file dialogue and lets you save the file with PNG MIME Type.

4
  • And how will Ubuntu read the mime type unless it is associated with an extension or there's a magic header?
    – ish
    Aug 2, 2012 at 9:14
  • In addition many Ubuntu applications choose the file format on "Save as..." from an extension you gave it.
    – Takkat
    Aug 2, 2012 at 11:48
  • @izx: exactly! mime types are stored in the file header itself.
    – Aras
    Aug 2, 2012 at 22:39
  • @Takkat: I added an example with Save as.. dialogue. Thanks!
    – Aras
    Aug 2, 2012 at 22:40
1

You rename it just as in Windows -- by changing the "extension", i.e. the part of the filename after the last .

To create autorun.inf, just right-click in Nautilus and click on "Create Document...Empty Document", and name it autorun.inf. It will open in the text editor (gedit) by default.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .