Sometimes we have directories full of audio files, images or of another type and that we want rename in bulk, Either because we want to give it another name or because they are files downloaded from some download network and that usually come with long names with the author, the web, etc. Many choose the difficult and slow way, which is to go one by one by naming them whatever they want.
So you don't complicate your life and you can rename entire directories in a simple way and without installing anything, you can access the console of your system and use the commands that we expose below with real examples of use so that it is easy for you to put them into practice.
- Imagine that you have downloaded a compressed directory containing 100 MP3 songs. These contain a name with this format «Audio XX-Audio Track By www.musica.com», where XX is the number of the song. If you wish get rid of part of the name, in this case of «By www.musica.com», the prefix «Audio» and the directory is in Downloads and is called Music:
cd /Descarga/Musica rename 's/ - By www.musica.com//g' *.mp3 rename 's/Audio - //'g *.mp3
- Imagine what you want now rename from a directory full of different .jpg images with a name like "Illustration.jpg" and we want names like "Photo.jpg". For that you can use:
cd /Descarga/Fotos rename y/Ilustración/Foto/ *.jpg
- Would you like change uppercase to lowercase or vice versato? No problem:
rename y/A-Z/a-z/ *.ext rename y/a-z/A-Z/ *.ext
- Remove and change the extension, respectively, from a directory full of files, for example .txt:
rename 's/\.txt$//' *.txt rename 's/\.txt$/\.bak/' *.txt
For more information, you can refer to the man pages for rename (man rename). Other options alternatives They are programs like pyRenamer, Metamorphose, KRename, GPRename, etc., which may be more intuitive and easier for you than using these commands ...
Thanks for these examples of the rename command. In Windows I select them all, I click on the first one and change the name, the rest are given the same name but adding consecutive numbers. Could you do something similar in Linux using the console?
How to do if the files have different names?
Would it be enough to put the wildcard "*" as the file name?
Thank you.