Given a directory with a large set of files using a spacer characters, here -
, how can they all be changed to use another spacer character, for example =
?
run-script-one.sh
→ run=script=one.sh
build-object-a.sh
→ build=object=a.sh
load-file-alpha.sh
→ load=file=alpha.sh
With prename
(Perl's standalone rename command):
prename -n 's/-/=/g' *.sh
Output:
build-object-a.sh renamed as build=object=a.sh load-file-alpha.sh renamed as load=file=alpha.sh run-script-one.sh renamed as run=script=one.sh
If everything looks fine, remove -n
(no action option).
If prename
is not available:
for i in *.sh; do echo mv -v "$i" "${i//-/=}"; done
Remove echo
if everything looks fine.