1

I have the following structure:

/mnt
--/source
----/file_groups
------/fg_1900
--------/A
--------/B
------/FG_1901

What I would like to do is rename all directories in the /file_groups folder to lowercase. But only the parent directory. So it will not change /A, or /B. However, it will rename /FG_1901 to /fg_1901.

I see this question/answer, but this will do it for all files/folders. I only want the parent folder, and not subs.

Any direction would be appreciated.

Community
  • 1
  • 1
CodeLikeBeaker
  • 19,633
  • 13
  • 75
  • 105

1 Answers1

2

You can tweak it like this:

cd file_groups

find . -type d -maxdepth 1 -exec rename 's/(.*)/\L$1/' {} \;

-maxdepth 1 will only go one level deep to find directories

anubhava
  • 713,503
  • 59
  • 514
  • 593