0

I am owner of Radio Station, and I have over 5000 tracks on my Cent OS PC. They are named like this

01. Craig David - Love Yourself (Live from BBC Radio's Live Lounge).mp3
01. The Maccabees - Hello (Live from BBC Radio's Live Lounge).mp3
02. Lukas Graham - 7 Years (Live from BBC Radio's Live Lounge).mp3
02. The Weeknd - Can't Feel My Face (Live from BBC Radio's Live Lounge).mp3
03. Blonde - Work - Pillowtalk - Children (Live from BBC Radio's Live Lounge).mp3
03. Olly Murs - Can't Stop the Feeling - Rock Your Body (Live from BBC Radio's Live Lounge).mp3
04. Coldplay - Adventure of a Lifetime (Live from BBC Radio's Live Lounge).mp3
04. One Direction - Four Five Seconds (Live from BBC Radio's Live Lounge).mp3
05. Jonas Blue - Hotter Than Hell (Live from BBC Radio's Live Lounge).mp3
05. Nick Jonas - Lush Life (Live from BBC Radio's Live Lounge).mp3
06. Fifth Harmony - Ex's & Oh's (Live from BBC Radio's Live Lounge).mp3
06. Jack Garratt - Worry (Live from BBC Radio's Live Lounge).mp3
07. Lower Than Atlantis - On My Mind (Live from BBC Radio's Live Lounge).mp3
07. Usher - Crash (Live from BBC Radio's Live Lounge).mp3
08. Gorgon City - One Dance (Live from BBC Radio's Live Lounge).mp3
08. Grace - You Don't Own Me (Live from BBC Radio's Live Lounge).mp3
09. Dua Lipa - The Hills (Live from BBC Radio's Live Lounge).mp3
09. Mike Posner - In Ibiza (Live from BBC Radio's Live Lounge).mp3
10. DNCE - Hands to Myself (Live from BBC Radio's Live Lounge).mp3
10. Shawn Mendes - Stitches (Live from BBC Radio's Live Lounge).mp3
11. James Bay - Hymn for the Weekend (Live from BBC Radio's Live Lounge).mp3
11. Karen Harding - PILLOWTALK (Live from BBC Radio's Live Lounge).mp3
12. The 1975 - Sorry (Live from BBC Radio's Live Lounge).mp3
12. Tom Odell - The Sound (Live from BBC Radio's Live Lounge).mp3
13. Alessia Cara - Hotline Bling (Live from BBC Radio's Live Lounge).mp3
13. Birdy - Fast Car (Live from BBC Radio's Live Lounge).mp3
14. Jamie Lawson - Wasn't Expecting That (Live from BBC Radio's Live Lounge).mp3
14. M.O - How Will I Know - Perfect Strangers (Live from BBC Radio's Live Lounge).mp3
15. CHVRCHES - This Is What You Came For (Live from BBC Radio's Live Lounge).mp3
15. Kygo - Wildest Dreams (Live from BBC Radio's Live Lounge).mp3
16. Bastille - 7 Days - Final Song (Live from BBC Radio's Live Lounge).mp3
16. Fleur East - Sax (Live from BBC Radio's Live Lounge).mp3
17. Biffy Clyro - (Live from BBC Radio's Live Lounge).mp3
17. Blossoms - In2 (Live from BBC Radio's Live Lounge).mp3
18. Charlie Puth - We Don't Talk Anymore (Live from BBC Radio's Live Lounge).mp3
18. Izzy Bizu - White Tiger (Live from BBC Radio's Live Lounge).mp3
19. Clean Bandit - Work from Home (Live from BBC Radio's Live Lounge).mp3
19. Laura Mvula - New Person, Same Old Mistakes (Live from BBC Radio's Live Lounge).mp3

I want to remove 01. from file names. I found a several same questions as mine, and no answer works for me in my centos 7 installation.

/^\d\d. /g

This is regex i came up with and it matches when i test it here

http://regexr.com/

But i have absolutely no idea how to implement it with sed, or find with rename. It's really blowing my mind...

3 Answers 3

2

With zsh:

autoload zmv # best in ~/.zshrc
zmv -n '<->. (*)' '$1'

Remove -n when happy.

<x-y> matches decimal number between x and y. <-> is any number.

0
1

A solution in only sed and sh:

for FILE in *.mp3
do mv "$FILE" "$(echo $FILE | sed -r 's/^[[:digit:]]{2}\. //g')"
done
1
  • i'll stick to zsh for now :D I do not want to "risk" anymore. Thanks for your answer though. Commented Jan 28, 2017 at 16:53
1

To just chop off the first four characters from a filename:

for fpath in path/to/songs/*.mp3; do
  fname="${fpath##*/}"
  newname="${fname:4}"
  echo mv "${fpath}" "${fpath%/*}"/"$newname"
done

Remove the echo once you are sure it's doing the right thing.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.