Friday, May 3, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 2664  / 1 Year ago, sat, february 25, 2023, 10:59:58

There is an answer that is very useful to me in this thread about renaming folders with trailing whitespaces:
Remove Leading or Trailing Space(s) in File or Folder Names


What I can't figure out how I can change the following command so that it also changes the names in subfolders.



rename -n 's/ *$//' *



I obviously already tried to check this myself with "rename -h" but I can;t see the solution.


Can someone help me with this?


Thanks a lot in advance,


Chris


More From » command-line

 Answers
0

You may just need to enable the globstar option of the bash shell then use **/* instead of *:


shopt -s globstar
rename -n 's/ *$//' **/*


  • where -n option is dry run.


[#2468] Sunday, February 26, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulild

Total Points: 239
Total Questions: 103
Total Answers: 112

Location: Papua New Guinea
Member since Thu, Jul 9, 2020
4 Years ago
fulild questions
Sat, Dec 11, 21, 20:10, 2 Years ago
Thu, Jun 17, 21, 12:05, 3 Years ago
Sat, Nov 19, 22, 16:28, 1 Year ago
Wed, Oct 12, 22, 04:04, 2 Years ago
Sun, Jul 31, 22, 08:07, 2 Years ago
;