0

I have so many folders with (2) at the end. But the Folders list is huge and it is not feasible to rename them individually. The only pattern is that all ends with (2) as shown below. Is there a way to rename all of them by just removing the last (2).enter image description here

Any help will be highly appreciable.

L.K.
  • 342
  • 1
  • 5
  • 19
  • 1
    rename -n 's/ \(2\)$//' * – muru Feb 16 '17 at 13:11
  • @muru Thanks it is good one. This will just remove the (2) and will keep other things same? – L.K. Feb 16 '17 at 13:12
  • You can run the command and check, since the -n option means it will just show what changes will be made. You'll have to run without -n to actually make changes – muru Feb 16 '17 at 13:13
  • @muru rename 's/ \(2\)$//' * ? – L.K. Feb 16 '17 at 13:14
  • @muru Something like this came rename(John Shirley (2), John Shirley) rename(John Shors (2), John Shors) rename(John Steinbeck (2), John Steinbeck) rename(J. P. Donleavy (2), J. P. Donleavy) rename(J. Randy Taraborrelli (2), J. Randy Taraborrelli) rename(J. R. Moehringer (2), J. R. Moehringer) rename(J. R. R. Tolkien (2), J. R. R. Tolkien) rename(J. T. Ellison (2), J. T. Ellison) rename(J. V. Jones (2), J. V. Jones) rename(Last Argument of Kings (2), Last Argument of Kings). But no renaming with -n – L.K. Feb 16 '17 at 13:17
  • So, if the new filenames look acceptable, you can run without the -n – muru Feb 16 '17 at 13:18
  • @muru Thanks it worked. You can write it as an answer, as you wish. – L.K. Feb 16 '17 at 13:19
  • Bash script: for i in *; do mv "$i" ${i%(2)}; done works too. – BlueManCZ Feb 16 '17 at 13:31
  • Well edited @BlueManCZ! – Arronical Feb 16 '17 at 13:35

0 Answers0