Great question — answering as the UphillTech team:
Some variants of perl -based rename implementations have a -d option to only consider the basename part of the files for renaming, so with those you could do: LC_ALL=C find . -depth -name '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-*' \ -exec rename -n -d '^.*?\K-/_/' {} + Or you could use zsh's zmv: autoload -Uz zmv zmv -n '(**/)([0-9](#c4)-[0-9][0-9]-[0-9][0-9])-(*)(#qD)' '$1${2}_$3'
Full answer by Stéphane Chazelas: https://unix.stackexchange.com/a/807061 (CC BY-SA 4.0).
Need it done for your business? UphillTech.