| View previous topic :: View next topic |
| Author |
Message |
mugstar LXF regular
Joined: Mon Apr 11, 2005 1:43 am Posts: 184 Location: Scotland
|
Posted: Mon Aug 07, 2006 12:13 am Post subject: bash: stripping numeric characters from filenames |
|
|
(I just know this will involve regular expressions ... )
I have a collection of mp3's and ogg's, a lot of which take the form 02_name_of_artist_name_of track.ogg. What I want to end up with is a file called name_of_track.ogg.
I know that I can use | Code: | | for i in *.ogg; do mv "$i" "${i/_name_of_artist_}"; done | to strip some of the filename out, but I'm messing up when trying to remove the track numbers from the start of more than one file.
Anybody? |
|
| Back to top |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 8002 Location: Warrington, UK
|
Posted: Mon Aug 07, 2006 12:32 am Post subject: Re: bash: stripping numeric characters from filenames |
|
|
| Code: | | for i in *.ogg; do mv "$i" "${i/[0-9][0-9]_name_of_artist_}"; done |
_________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
mugstar LXF regular
Joined: Mon Apr 11, 2005 1:43 am Posts: 184 Location: Scotland
|
Posted: Mon Aug 07, 2006 12:45 am Post subject: RE: Re: bash: stripping numeric characters from filenames |
|
|
Aargghhh!! Two seperate ones!
Thanks! |
|
| Back to top |
|
 |
emyr42 LXF regular

Joined: Tue Nov 22, 2005 9:16 am Posts: 147 Location: Cardiff, UK
|
Posted: Mon Aug 07, 2006 12:13 pm Post subject: RE: Re: bash: stripping numeric characters from filenames |
|
|
Shouldn't your code be reading from the ogg file's metadata to find the track name? _________________ OpenSUSE 10.2, WinXPHome
AMD Sempron 2400, 512MB DDR333, Twin 60GB Deathstars |
|
| Back to top |
|
 |
nordle LXF regular

Joined: Fri Apr 08, 2005 10:56 pm Posts: 1497
|
Posted: Tue Aug 08, 2006 10:08 pm Post subject: RE: Re: bash: stripping numeric characters from filenames |
|
|
02_name_of_artist_name_of track.ogg
But surely the best you can ever hope for with pattern matching is
name_of_artist_name_of track.ogg
Unless you started with something like:
02_name_of_artist__name_of track.ogg _________________ I think, therefore I compile |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|