Can I rename multiple directories?

QuestionsQuestions8 SkillsProBasic Files OperationsNov, 14 2025
080

The mv command does not support renaming multiple directories in a single command directly. However, you can use a loop in a shell script or command line to rename multiple directories. Here's an example using a for loop in a bash shell:

for dir in old_name1 old_name2 old_name3; do
    mv "$dir" "new_name_${dir#old_name}"
done

In this example, replace old_name1, old_name2, and old_name3 with the names of the directories you want to rename, and adjust the new_name_ prefix as needed. The ${dir#old_name} syntax removes the old_name prefix from the directory name for the new name.

Make sure to adjust the logic according to your specific renaming needs.

0 Comments

no data
Be the first to share your comment!