Remove all leading spaces in folder / file names

I created a command to remove all leading spaces of all folder / file names in a directory (with subdirectories).

find /dir/* -depth -execdir rename 's/^\s+//g' * "{}" \; 

It works in some small directories (with some subdirectories), but for large directories it lasted a lot . I see that the command takes longer to complete than necessary, but I don’t know why.

Can anyone suggest how to speed it up?

/ edit: I use Debian 8.2 as an OS.

+4
source share
1 answer

, , -execdir find. rename , , . rename *, N rename N ^ 2. (+1 "{}", find.)

, rename - *. , "{}".

, ( ):

  • -regex, , .
  • + ; .
  • *.
  • rename (find ./).

, / , rename * . Gut, , , , .

(, -!)

+1

Source: https://habr.com/ru/post/1621357/


All Articles