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"
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"
You can try this:
$ tree foo
foo
├── dir_1
│ └── foo_file_2
└── file_1
1 directory, 2 files
$ for ft in d f; do find foo -type $ft -execdir sh -c 'mv "$0" "${0//_/-}"' {} \; ; done 2>/dev/null
$ tree foo
foo
├── dir-1
│ └── foo-file-2
└── file-1
1 directory, 2 files
This renames all directories and then all files (the for
loop over d f
) because I haven't been able to make it do all renaming in one iteration.