[ILUG] Strip first three characters from filename

Paschal Nee pnee at toombeola.com
Sun Aug 10 12:27:26 IST 2008


Yet another way of doing this using the built in bash string
manipulation instead of calls to cut/gawk/etc
http://tldp.org/LDP/abs/html/string-manipulation.html

for filename in *.mp3; do mv ${filename} ${filename:3}; done;

Paschal.

ollie at eillo.org wrote:

    I have a ton of mp3 files that I'm currently sorting the id3 tags for.
    Each filename starts with the tracknumber followed by an underscore.

    e.g. 01_SONG_NAME_-_ARTIST_NAME_-_ALBUM_NAME.mp3

    Because i have a unique separator between the SONG, ALBUM and BAND
name '_-_'
    i can use my audio tag software to populate the ID3 tag fields
appropriately.

    However the track number is separated from the band name by an
underscore and the software isn't flexible enough to tell the
difference.

    So i need a shell script that will loop through a directory and
    strip the first three characters from each filename.

    Can this be easily done in shell?

    If not i can do it in python but id rather not.

    Cheers,
          Oliver.



More information about the ILUG mailing list