|
Prev: cheap wholesale:nike shoes,Nike air jordans,wholesale nike a
Next: Shell audio oscilloscope journey
From: Luuk on 19 Apr 2008 14:50 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" i created the following (bash-)script: #!/bin/bash s=$1 n=${s/$2.$3/$3} mv -v "$1" "$n" <END OF SCRIPT> i can do: $ script name.wav.mp3 wav mp3 and this will rename my file but i do not like this 2nd and 3rd parameter, so i want to do: $ script name.wav.mp3 but how can this be done? can anyone point me to the right direction? -- Luuk
From: Stephane CHAZELAS on 19 Apr 2008 15:29 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). -- St�phane
From: Kenny McCormack on 19 Apr 2008 16:40 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.
From: mop2 on 19 Apr 2008 17:23 I think this is what you want: #!/bin/bash mv -v "$1" "${1/.wav/}" Luuk 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" > > i created the following (bash-)script: > #!/bin/bash > > s=$1 > n=${s/$2.$3/$3} > > mv -v "$1" "$n" > <END OF SCRIPT> > > i can do: > $ script name.wav.mp3 wav mp3 > and this will rename my file > > but i do not like this 2nd and 3rd parameter, so i want to do: > $ script name.wav.mp3 > but how can this be done? > > can anyone point me to the right direction? > > -- > Luuk
From: mop2 on 19 Apr 2008 17:27 I think this is what you want: #!/bin/bash mv -iv "$1" "${1/.wav/}" # "i" = interative if destination exists Luuk 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" > > i created the following (bash-)script: > #!/bin/bash > > s=$1 > n=${s/$2.$3/$3} > > mv -v "$1" "$n" > <END OF SCRIPT> > > i can do: > $ script name.wav.mp3 wav mp3 > and this will rename my file > > but i do not like this 2nd and 3rd parameter, so i want to do: > $ script name.wav.mp3 > but how can this be done? > > can anyone point me to the right direction? > > -- > Luuk
|
Next
|
Last
Pages: 1 2 3 Prev: cheap wholesale:nike shoes,Nike air jordans,wholesale nike a Next: Shell audio oscilloscope journey |