0

i'm trying to automate a process, and for that, I need to strip a part of a foldername.
Folders are named dummy1R1, dummy2R1, dummyLongerR1. I need to strip the R1 from the folder names, for a certain parent folder.
I have looked into "rename" but that only works for files, and "find" doesn't show me if I can reuse a grouping in regex.

All help appreciated

ShadowFlame
  • 2,996
  • 5
  • 26
  • 40

1 Answers1

3

If you are using bash, you can use the variable expansion. Also "mv" does work on Linux to rename a directory.

So

for d in *R1
do
    mv $d ${d%%R1}
done

For all entries ending in "R1" rename it to the name with the "R1" removed. For more information, look at the bash manual page, the section on "Parameter Expansion"

Beano
  • 7,551
  • 3
  • 24
  • 27