To Install Rename on Ubuntu sudo apt install rename I will demonstrate the Perl version of rename command. Note: There are 2 versions of rename command available and they both have different syntax. This command requires basic knowledge of regular expressions.įirst, you have to install the rename command on your Linux distro. Rename command is used to rename multiple files. The mv command is a handy tool to rename single files, but if you want to rename multiple files, then you have to use a tool that is specifically made for this. Rename Files in Linux using the rename Command As I said it was not made as a renaming tool, to begin with.īasically, it doing: mv file1.jpg file1.pngįor each and every file in the current directory (with “.jpg” extension) in loop. There is no way to rename multiple files using only the mv command. mv /home/user/Desktop/file.jpg /home/user/Desktop/hello.jpg Rename Multiple Files in Linux using mv Command If the file is in a different location, you can provide a full path in the mv command. The above command will rename the file.jpg to hello.jpg. To rename “file.jpg” to “hello.jpg” use the mv command followed by the source and destination file names separated by a space. Rename a Single file using the mv Command So, to rename a file, you need to specify a single file as a source and make sure no directory exists with the new name you want to give to your source file. If you specify multiple files as source, then the destination must be a directory so that all the source files are moved into the destination directory.Īlso, if you specify a single file as the source and the destination is an existing directory, then the source file is moved to that directory. Yes! The source can be single or multiple files or even directories (folders).ĭestination: The destination can be a single file or directory. Here’s the basic syntax of the mv command: mv So, it also works as a utility to rename files. The mv command is officially made for moving files, but when it moves a file from one location to another, you can give the file a new name. Rename Files in Linux Using the mv Command In my other post, I have shown how you can use them to rename directories in Linux. Note: mv and rename commands can be used to rename both files and directories (folders). Renaming any single file is easy in Linux using a terminal but renaming multiple files at once can give you a headache.ĭon’t worry, I will show you how to rename both single and multiple files easily using the mv and rename command. In this tutorial, I will show you how to rename files in Linux using Terminal.
0 Comments
Leave a Reply. |