1

I want to write a bash script to rename files, directories, and softlinks by adding a string at the end of the names. I have written this code:

#!/bin/bash

if [ -d "$1" ]
    then
        cd $1
        find -type f -exec mv -v {} {}etc \;
        find -type d -exec mv -v {} {}dir \;
        find -type l -exec mv -v {} {}softlink \; 
else
    echo "ERROR"
fi

The problem is that the find with the -d parameter wants to rename not only the directories in the $1 parameter, but the . directory too, at this point the bash throws an error saying the . can't be moved or renamed. What have I done wrong?

compuphys
  • 1,289
  • 12
  • 28

0 Answers0