![]() |
String manipulation in bash
I'm trying to make a bash script for nautilus that converts a flv-file to mpg. I can't rename the new file properly. The file name.flv should be called name.mpg when converted. Pretty simple. The basic idea is this:
Code:
#!/bin/bash"$1""$b"mpg: is output filename I've tried many different versions of this, but the best of them only converts to a filename where the backspace characters are reckognized as some weird symbol. How do I manipulate the string properly? |
Code:
b=${1/flv/mpeg}substitution edit: ah not the good variable, this is one correct answer: ffmpeg -i "$1" ${1/flv/mpeg} |
Hi,
Something like this should work: ${1%%.flv}.mpg ffmpeg -i "$1" ${1%%.flv}.mpg (i did not check to see if the quotes are needed). This uses bash' parameter expansion (see manpage for more details). Hope this helps. |
Thanks. Both suggestions work.
|
There is also
for x in *flv; do ffmpeg -i "$x" "${x/.flv/.mpg}";done If you have a big job to do and want to take lunch early. |
| All times are GMT -5. The time now is 09:33 AM. |