

This is also not changing the file names, it is only changing the extension that comes as a file suffix.

We have plenty of articles about various file format and type conversions if you’re interested in that, however.

The command line approach to changing file extensions is quite fast and the file extensions will be changed rapidly, with no warning dialogs or confirmations.Īnd to reiterate once again, this is not to convert any file types or change anything but the file extension name.Remember this is only changing the file extension, this is not actually changing the file type or performing any file conversion. Assuming you are in the directory where you wish to change all files in the current directory to a new file extension, here is the syntax to use:įor file in *.txt do mv "$file" "$.jpeg" done In the first example, we’re going to change all files in the present working directory with the extension “.txt” and change them to “.py” instead. How to Change All File Extensions in a Directory via the Command Line Failure to do so could result in data loss, the Terminal is unforgiving to typos or mistakes, so don’t skip your backups. OK? Alright on to the command line approach using a simple one line bash script.īy the way you should always make a copy and/or backup of the files you are modifying, particularly if you are new to the command line. However, the Terminal is not the only way to do this, and so if this is too advanced or irrelevant to your user skill set then recall that Mac OS offers simple tools to both batch rename files in Mac OS and batch change file extensions in the Finder as well, neither of which requires the command line at all. Additionally, this walkthrough approach is intentionally using the command line and is thus aimed at more advanced users. Before beginning, realize this is not changing a file type, it is only changing the file extension.
