I got a bunch of mp3 files with random names and numbers like:
- 01_fileabc.mp3
- 01.filecdc.mp3
- fileabc.mp3
- 929-audio.mp3
For sorting purposes, I need to add a sequential number in front of the file name like:
- 001_01_fileabc.mp3
- 002_01.filecdc.mp3
- 003_fileabc.mp3
- 004_929-audio.mp3
I checked some of the solutions I found here. One of the first solutions worked kind of but replaced the filename instead of adding to it.
num=0; for i in *; do mv "$i" "$(printf '%04d' $num).${i#*.}"; ((num++)); done
How can I modify this command to add to the filename instead? I am sorry, but whatever I try I can't find a solution myself here.