I need to rename only directories and not files, and I want to do it with rename
.
Is there any way to do it?
It says nothing in the manual about differentiating between directories and files.
This command changes everything, no matter directory or files:
rename 's/ /\n/g' *
This command solved my problem:
rename 's/ /\n/g' */
I need a slash behind it.
rename
does not distinguish between files and folders.The shell is responsible for expanding the wildcard
*
into files and folders.*
will be expanded to all non-hidden files and folders.*/
will be expanded to all non-hidden folders.But I don't know of any way to expand to files only. You can use
find -exec
instead.only folders:
or
Only files:
Note that
find
will also find hidden files unlike*
(unless you turn on thedotglob
shell option by runningshopt -s dotglob
).zsh
seems to be able to match files only with wildcards.