rename tool is extremely non-portable; there is almost nothing in common between the RHEL/CentOS/Fedora family version of
rename and the version found on Ubuntu or Debian.
I wrote an answer giving example usage for both versions of
rename a while back.
You haven’t said what OS you’re using, so it’s hard to be very specific—and since this is homework, you should do some work on it yourself so I will not spell out the answer even if you say which OS.
However, a couple of tips:
sedoperates on the contents of a text file; it does not change the name of a file and certainly not the name of a directory. It cannot be used for that, and that’s why you get errors from the command you wrote.
- You are on the correct track with your
- I suggest you look up the
findas they may come in handy (you don’t need to try to rename files that don’t match the given pattern).
rename(the appropriate version for your OS) is probably the easiest/best solution for this.
You can use the
rename tool. An example of this use case is:
rename section chapter *
Or in your case, you would probably pipe the output of find.
find . -type d -print | xargs rename section chapter