From: Dave B on
On Sunday 20 April 2008 14:43, Kenny McCormack wrote:

>>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.

With the shell approach there are no quoting problems whatsoever. The fact
is, with a shell approach you can just do

....
newname=${whatever}
mv -- "$name" "$newname"

and be done with that, without having to worry about special characters.
(if you care, you can do
printf "name is %s, newname is %s\n" "$name" "$newname"
before doing the actual mv, to check that everything is ok; it usually is).

With vim, on the other hand, you're writing the actual filenames in mv
commands, so you have to be *much more* careful. If filenames don't have
single quotes, that that's easy. But if they do (and music files probably
do), you have to properly escape and quote everything, and it's easier
(imho) to visually miss wrongly escaped characters, especially if you have
200 filenames like

03 - "Want $$?"--'Take this sh*t!'(hax0r_rul3z).wav.mp3

(ok that's just an example, of course, but hopefully you got the idea).

But then, if you do that with vim, then you can also do the same with sed:
you can still inspect the result before feeding it to sh, and it has the
advantage of being more easily scriptable.

Note: I'm all for (awk/sed | sh) -based approaches to mass renaming files,
when the names have regular and predictable patterns. In the case of music
files, that is not usually true, so I prefer a shell-based solution.

--
D.
From: Kenny McCormack on
In article <fufr7j$t77$1(a)registered.motzarella.org>,
Dave B <daveb(a)addr.invalid> wrote:
....
>Note: I'm all for (awk/sed | sh) -based approaches to mass renaming files,
>when the names have regular and predictable patterns. In the case of music
>files, that is not usually true, so I prefer a shell-based solution.

Yes, you do. Because you are (presumably) competent, and have done this
before. You know enough to try it out in a test directory first, and to
proceed cautiously until you are familiar with what's going on.

The problem is that people post shell solutions on newsgroups and the OP
tries them out directly, without doing the necessary QA. And there's
always _something_ just a little bit subtly wrong with the posted
solution. You (meaning "one", not you, "Dave B") are always going to
have to massage it a little to make it work for you, in _your_
environment.

I would never just pipe it into sh, as you indicate above. That blows
the safety of writing it to a file, inspecting the file, and then,
finally, sourcing the file.

From: Dave B on
On Sunday 20 April 2008 18:52, Kenny McCormack wrote:

> Yes, you do. Because you are (presumably) competent, and have done this
> before. You know enough to try it out in a test directory first, and to
> proceed cautiously until you are familiar with what's going on.
>
> The problem is that people post shell solutions on newsgroups and the OP
> tries them out directly, without doing the necessary QA. And there's
> always _something_ just a little bit subtly wrong with the posted
> solution. You (meaning "one", not you, "Dave B") are always going to
> have to massage it a little to make it work for you, in _your_
> environment.

Sorry for being slow to understand, but my point is that a shell solution
can be tried directly without problems by everyone. The OP could have
copied/pasted my solution directly and used it on *any* file, regardless of
its name, and it would have worked.
The vim approach imho gives a false sense of security, because you simply
can't be sure you've properly escaped everything in a list of 2000
arbitrarily complex filenames, even if you are sitting in front of it.

> I would never just pipe it into sh, as you indicate above. That blows
> the safety of writing it to a file, inspecting the file, and then,
> finally, sourcing the file.

If you know in advance that all the files are named

AAABBBCCC.aaa

where AAA, BBB and CCC are numbers, and aaa are letters, there is no reason
to worry in piping the output to sh. Simply, that is not the case with
music (or multimedia, for that matter) files.

--
D.
From: Marcel Bruinsma on
In article <0hrpd5-brr.ln1(a)a62-251-88-195.adsl.xs4all.nl>,
Luuk wrote:

> 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"

$ rename .wav. . *.wav.mp3

gr.

From: Luuk on
Marcel Bruinsma schreef:
> In article <0hrpd5-brr.ln1(a)a62-251-88-195.adsl.xs4all.nl>,
> Luuk wrote:
>
>> 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"
>
> $ rename .wav. . *.wav.mp3
>
> gr.
>

thanks/bedankt/merci

many ways to Rome...

--
Luuk