How to Change a File’s Extension on Windows and Linux

Photo of author

By Victor Ashiedu

Published

Users and Systems admins have scenarios in which they may need to change the extension of a file. If you need to perform this common task, use one of the methods below.

The screenshots and steps in this article were taken from Windows 11 and Ubuntu (for the Linux section). If you perform the steps in Windows 10, there may be slight variations in what you see.

Option 1: Change File Extension on Windows with File Explorer

By default, when you view files in Windows File Explorer, the extensions are hidden. Therefore, to be able to modify the extension of a file, you must first configure File Explorer to unhide extensions of known file types.

Step 1: Change File Explorer File Extension Settings

  1. Right-click the Windows Start menu and select “File Explorer.”
configure File Explorer to unhide extensions of known file types - step 1
  1. Then, on the top of the Windows 11 File Explorer, click the menu (3 dots) and select Options.
Then, on the top of the Windows 11 File Explorer, click the menu (3 dots) and select Options
  1. When the File Explorer Options open, click the View tab, then uncheck “Hide extensions of known file types.” Click OK to save your changes.
When the File Explorer Options open, click the View tab, then uncheck hide extensions of known file types

After completing this step, Windows will now display all file extensions.

Step 2: Change the Extension of a File

  1. Right-click the file you want to modify its extension and select “Show more options,” then select Rename. In this example, I am changing the extension of text file (“.txt”) to “.dll.”
Right-click the file you want to modify its extension and select Show more options, then select Rename
  1. To change the file extension, move your mouse to the end of the current extension and replace it with the new extension. Windows will request a confirmation, select Yes.
DO NOT replace the period (“.”) between the file name and its extension
To change the file extension, move your mouse to the end of the current extension and replace it with the new extension
Windows will request a confirmation, select Yes

Step 3: Revert File Explorer File Extension Settings

When you finish, it is a good idea to open File Explorer Options -> View tab and check the “Hide extensions of known file types.”

Step 3 - Revert File Explorer File Extension Settings

Option 2: Change File Extension on Windows with PowerShell

Changing the extension of a file with PowerShell is very straightforward.

The first step is to open PowerShell as an administrator. Then, run a command like mine below.

The command modifies the extension of the file I changed in the last section from Servers.dll to Servers.txt
Get-ChildItem D:\reports -Recurse -Include Servers.dll | Rename-Item -NewName Servers.txt
Change File Extension in Windows with PowerShell 1
Change File Extension in Windows with PowerShell 2
Change File Extension in Windows with PowerShell

Option 3: Change File Extension on Linux (Terminal and GUI)

Just like with PowerShell in Windows, modifying the extension of a file in Linux is pretty easy.

All you require is the mv command. Here is the basic syntax of this command:

mv current-filename.ext current-filename.newext

To show a real-life example, I will run the mv command on the Git Bash terminal on my Windows 11 PC.

The command below changes the extension of the text file, Servers.txt to Servers.sh. Before running the command, I changed directory to the location of the file. Also, to show the file extension before and after, I ran the “ls” command.
mv Servers.txt Servers.sh
Change File Extension on Linux with mv Command

If you’re wondering how to change file extension via GUI, it is quite simple as well. Right-click the file and select Rename.

Change File Extension on Linux GUI

Finally, change the file’s extension and click Rename.

Conclusion

Modifying the extension of a file on Windows or Linux is a common exercise but it is fairly easy. In this guide, I have explained the steps to perform this task on the two Operating Systems.

Thank you for visiting our site and I hope this article met your expectations. If it did, kindly let me know by responding to the “Was this page helpful?” question below.

Finally, before you go, you may benefit from browsing our other guides on the Windows 11 How-to Guides or Linux How-to Guides page.

Thanks again!

About the Author

Photo of author

Victor Ashiedu

Victor is the founder of InfoPress Media, publishers of Ilifeguides and Itechguides. With 20+ years of experience in IT infrastructure, his expertise spans Windows, Linux, and DevOps. Explore his contributions on Itechguides.com for insightful how-to guides and product reviews.

Related Articles

Get in Touch

We're committed to writing accurate content that informs and educates. To learn more, read our Content Writing Policy, Content Review Policy, Anti-plagiarism Policy, and About Us.

However, if this content does not meet your expectations, kindly reach out to us through one of the following means:

  1. Respond to "Was this page helpful?" above
  2. Leave a comment with the "Leave a Comment" form below
  3. Email us at [email protected] or via the Contact Us page.

Leave a comment

Send this to a friend