Aqui está algo que você pode fazer usando apenas bash
, com um regex em um condicional :
#! /bin/bash
# get all files that start with a number
for file in [0-9]* ; do
# only process start start with a number
# followed by one or more space characters
if [[ $file =~ ^[0-9]+[[:blank:]]+(.+) ]] ; then
# display original file name
echo "< $file"
# grab the rest of the filename from
# the regex capture group
newname="${BASH_REMATCH[1]}"
echo "> $newname"
# uncomment to move
# mv "$file" "$newname"
fi
done
Quando executado nos nomes dos arquivos de amostra, a saída é:
< 01 American Idiot.mp3
> American Idiot.mp3
< 01 Articolo 31 - Domani Smetto.mp3
> Articolo 31 - Domani Smetto.mp3
< 01 Bohemian rapsody.mp3
> Bohemian rapsody.mp3
< 01 Eye of the Tiger.mp3
> Eye of the Tiger.mp3
< 04 Halo.mp3
> Halo.mp3
< 04 Indietro.mp3
> Indietro.mp3
< 04 You Can't Hurry Love.mp3
> You Can't Hurry Love.mp3
< 05 Beautiful girls.mp3
> Beautiful girls.mp3
< 16 Apologize.mp3
> Apologize.mp3
< 16 Christmas Is All Around.mp3
> Christmas Is All Around.mp3