How to rename all files and folder containing underscore?

I want to rename all files and folder containing underscore in name and replace underscore with hyphen.

Currently I am using following code,

rename '_' '-' */*/*

It was working but now it is showing me "Argument list too long"

Please help!

Try

rename '_' '-' */*/*_*

or

find . -depth -name '*_*' -exec rename '_' '-' {} +
1 Like

My Favourite one liner always work for large number of files.

CODE
for i in *_*;do mv $i ${i//"_"/"-"};done