title: Rename directories recursively from pascal or camel case to kebab case
body: <p>It would be best if I could just use the rename command. But I think we have to use two regex.</p>
  <p>The <a href="https://stackoverflow.com/a/8503127">sed command that is working</a> is</p>
  <pre><code>% echo MyExPression | sed --expression 's/\([A-Z]\)/-\L\1/g' --expression 's/^-//'                         
  my-ex-pression
  % echo myExPression | sed --expression 's/\([A-Z]\)/-\L\1/g' --expression 's/^-//'
  my-ex-pression
  </code></pre>
  <p>I <a href="https://askubuntu.com/a/844752">figured out</a> that we can use</p>
  <pre><code>for file in ./* ; do mv &quot;$file&quot; &quot;$(echo $file|sed -e 's/\([A-Z]\)/-\L\1/g' -e 's/^.\/-//')&quot; ; done
  </code></pre>
  <p>But this command has multiple problems.</p>
  <ol>
  <li>It operates on both files and directories. I want to rename directories only</li>
  <li>It does not loop recursively.</li>
  <li>If kebab case filename is already there then it says
  <code>mv: cannot move './first-folder-to-rename' to a subdirectory of itself, './first-folder-to-rename/first-folder-to-rename'</code></li>
  </ol>
  <p>So, what might be the solution here?</p>
  <p><strong>Update 1</strong></p>
  <p>Here is a sample directory structure</p>
  <pre><code>% tree
  .
  ├── EmptyFile.txt
  ├── FirstDirectoryName
  │   ├── FourthDirectoryName
  │   ├── secondDirectoryName
  │   └── thirdDirectoryName
  ├── FourthDirectoryName
  ├── secondDirectoryName
  └── thirdDirectoryName
  </code></pre>
  <p>Expected Output</p>
  <pre><code>% tree
  .
  ├── EmptyFile.txt
  ├── first-directory-name
  │   ├── fourth-directory-name
  │   ├── second-directory-name
  │   └── third-directory-name
  ├── fourth-directory-name
  ├── second-directory-name
  └── third-directory-name
  </code></pre>