I've a problem modifying the files' names in my
Music/
directory.
I have a list of names like these:
$ ls
01 American Idiot.mp3
01 Articolo 31 - Domani Smetto.mp3
01 Bohemian rapsody.mp3
01 Eye of the Tiger.mp3
04 Halo.mp3
04 Indietro.mp3
04 You Can't Hurry Love.mp3
05 Beautiful girls.mp3
16 Apologize.mp3
16 Christmas Is All Around.mp3
Adam's song.mp3
A far l'amore comincia tu.mp3
All By My Self.MP3
Always.mp3
Angel.mp3
And similar and I would like to cut all the numbers in front of the filenames (not the 3 in the extension).
I've tried first to grep
only the files with the number with find -exec
or xargs
but even at this first step I had no success. After being able to grep
I'd like doing the actual name change.
This is what I tried by now:
ls > try-expression
grep -E '^[0-9]+' try-expression
and with the above I got the right result. Then I tried the next step:
ls | xargs -0 grep -E '^[0-9]+'
ls | xargs -d '\n' grep -E '^[0-9]+'
find . -name '[0-9]+' -exec grep -E '^[0-9]+' {} \;
ls | parallel bash -c "grep -E '^[0-9]+'" - {}
And similar but I got error like 'File name too long' or no output at all. I guess the problem is the way I'm using xargs
or find
as expressions in separate commands work well.
Thank you for your help
Asked by Luigi Tiburzi
(887 rep)
May 29, 2012, 08:07 AM
Last activity: May 14, 2025, 11:19 AM
Last activity: May 14, 2025, 11:19 AM