From: Dave B on
On Saturday 19 April 2008 23:27, mop2 wrote:

> I think this is what you want:
>
> #!/bin/bash
> mv -iv "$1" "${1/.wav/}" # "i" = interative if destination exists

Given that sometimes audio files tend to have, so to speak, particular or
funny names, maybe a safer one could be this:

mv -i -- "$1" "${1%.wav.mp3}.mp3"

or, with bash+GNU mv

mv -iv -- "$1" "${1/%.wav.mp3/.mp3}"

--
D.
From: Kenny McCormack on
In article <fuf64n$uhm$1(a)registered.motzarella.org>,
Dave B <daveb(a)addr.invalid> wrote:
>On Saturday 19 April 2008 23:27, mop2 wrote:
>
>> I think this is what you want:
>>
>> #!/bin/bash
>> mv -iv "$1" "${1/.wav/}" # "i" = interative if destination exists
>
>Given that sometimes audio files tend to have, so to speak, particular or
>funny names, maybe a safer one could be this:
>
>mv -i -- "$1" "${1%.wav.mp3}.mp3"
>
>or, with bash+GNU mv
>
>mv -iv -- "$1" "${1/%.wav.mp3/.mp3}"

Which is a further argument in favor of doing this carefully and safely,
as indicated in my previous post. It is easier to get the quoting right
when the commands are in front of you onscreen, rather than trying out
some cryptic command that is likely to do some damage before you figure
out what is going on.

From: Luuk on
Kenny McCormack schreef:
> In article <0hrpd5-brr.ln1(a)a62-251-88-195.adsl.xs4all.nl>,
> Luuk <Luuk(a)invalid.lan> wrote:
>> Hi,
>>
>> I was converting some *.m4a files to *.mp3 and ended up with files like:
>> "name.wav.mp3"
>>
>> i want to rename them from "name.wav.mp3" to "name.mp3"
>
> The best way to do this, under the following very common assumptions:
> 1) You've not done this sort of thing before and am not real
> comfortable with it (this is why you're asking here).
> 2) You probably won't be doing this again for quite some time
> (i.e., this is a one-off).
>
> is to do it like this:
>
> ls <files> > foo
> vi foo
>
> Bring up foo in an editor (usually vi, but use what you are comfortable with) and change every instance of:
>
> name.wav.mp3
> to:
> mv name.wav.mp3 name.mp3
>
> The advantage here is that you can see onscreen what is happening -
> makes for fewer surprises. When you are happy with it, save and exit
> your editor, then "source" foo.
>
> Note that if you are using GNU tools, there are some options to the "mv"
> command, such as "-v" that should be useful. Note also that if you have
> access to the "mmv" command (very useful, BTW), then you can use that
> for further safety.
>
> The point to all this is that safety is the important thing, not
> elegance or efficiency. Take it from one who knows - who has on
> occasion worked up spiffy (but not quite spiffy enough) shell solutions
> to this - only to have something go wrong.
>

sure, the SAFE way....
i do (did) this a lot (solving the probling using VI),
but i wanted to go for an option to script this, and 'solve' this in a
more generic way....;-)

--
Luuk
From: Luuk on
Stephane CHAZELAS schreef:
> 2008-04-19, 20:50(+02), Luuk:
> [...]
>> I was converting some *.m4a files to *.mp3 and ended up with files like:
>> "name.wav.mp3"
>>
>> i want to rename them from "name.wav.mp3" to "name.mp3"
> [...]
>
> zmv '(*).wav.mp3' '$1.mp3'
>
> (zmv is a zsh autoloadable function).
>

too lazy to learn zsh, and its disadvantages or advantages,
because i'm still bussy getting to know more about bash ... ;-)

--
Luuk
From: Luuk on
Dave B schreef:
> On Saturday 19 April 2008 23:27, mop2 wrote:
>
>> I think this is what you want:
>>
>> #!/bin/bash
>> mv -iv "$1" "${1/.wav/}" # "i" = interative if destination exists
>
> Given that sometimes audio files tend to have, so to speak, particular or
> funny names, maybe a safer one could be this:
>
> mv -i -- "$1" "${1%.wav.mp3}.mp3"
>
> or, with bash+GNU mv
>
> mv -iv -- "$1" "${1/%.wav.mp3/.mp3}"
>

yes, i did already have the quotes around my filenames, because of the
spaces in the filenames...

anyway, the "${1/%...." option, is new to /me, and helped a lot

i have to read the 'man bash' page again, i think,
and this time try to read the whole story
so, not stop before the lines about 'Parameter Expansion' (line 756-)
... ;-)

thanks for the answers!

--
Luuk