Posted: 31 January 2020. At: 10:45 AM. This was 4 years ago. Post ID: 14009
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

Renaming folders with a loop in bash is easy.

Renaming folders is very easy. I have a folder with subdirectories named from 1 to 9. And I wish to rename them folder1 to folder9. This can be easily done with bash.

This example will take care of this problem easily.

4.4 Fri Jan 31 jason@Yog-Sothoth 0: $ for i in $(seq 9);do mv $i folder$i;done

The $(seq 9); value is how many folders are to be renamed.

Another good way to rename files is with a GUI. A plugin for Caja can help with this task.

Install it like this.

Renaming a batch of files in Caja with a plugin.
Renaming a batch of files in Caja with a plugin.

This works very well, the preview updates as you type, so you can see how it will affect the files before committing your changes. This is a very nice addition to your Linux Mint or Ubuntu MATE desktop and automates a lot of tasks if you are not the best at shell scripting.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.