Convert wav to mp3 with a right click option

Audio editors, music players, video players, burning software, etc.
Message
Author
User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#21 Post by don570 »

another loop example with for statement

Code: Select all

#!/bin/bash
echo "Argument value is: $1"

for item in "$@"
do
echo "Argument value is: $item"
done


terminal output is


# ./script 1 2 4 6
Argument value is: 1
Argument value is: 1
Argument value is: 2
Argument value is: 4
Argument value is: 6

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#22 Post by RSH »

Hello don570,

thank you for your help.

After help and hints from big_bass, emil, L18L, PANZERKOPF, rhadon and you, i was able to create the tool, i wanted to create. It works fine. Now i have to put all these things together (saving to hd) and study it. There's a lot of documentation i've found.

The Tool is created as ROX-App, like your Audiotools. The Code is fully commended in german and english. So, i think, you should take a look inside, because if have found out something interesting about:

Code: Select all

t="${z%.*}"
The pet is here:

http://murga-linux.com/puppy/viewtopic. ... 2&start=15

RSH

Edit:
You seem to know more about programming
than me. It's the blind leading the blind. Laughing
Let me tell you something to this. From Time to Time i've been working as a teacher for playing drums. In the private sector and even on schools. So, everytime i've teached anybody, i've learned something at the same time. And for sure, i've learned from your posts as well.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#23 Post by don570 »

I've been studying loops and here's some things
I've learned. I show the script ,
then the output in the terminal.

Here's a quick way of making a list for a loop
to use each word as an argument

Code: Select all

#!/bin/bash

LIST='apple orange pear plum'
for item in $LIST
do
echo "Argument value is: $item"
done
# ./script
Argument value is: apple
Argument value is: orange
Argument value is: pear
Argument value is: plum

Here is the usual way programmers make a list

Code: Select all

#!/bin/bash

LIST='apple
orange
pear
plum'
for item in $LIST
do
echo "Argument value is: $item"
done
# ./script
Argument value is: apple
Argument value is: orange
Argument value is: pear
Argument value is: plum

Double quotation marks are useless as this example
shows...

Code: Select all

#!/bin/bash

LIST=$(echo "ap ple" orange pear plum)
for item in $LIST
do
echo "Argument value is: $item"
done
 
# ./script
Argument value is: ap
Argument value is: ple
Argument value is: orange
Argument value is: pear
Argument value is: plum


Now I change the IFS (Internal Field Separator) to a comma
and the white space is protected

Code: Select all

#!/bin/bash
IFS=,
LIST='ap ple,orange,pear,plum'
for item in $LIST
do
echo "Argument value is: $item"
done
# ./script
Argument value is: ap ple
Argument value is: orange
Argument value is: pear
Argument value is: plum

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

loop example

#24 Post by don570 »

The following example will loop three times
even though there are 4 arguments

Code: Select all

#!/bin/bash
 
x=1
while [ $x -le 3 ]
do
echo “argument is ....$1″
shift
x=`expr $x + 1`
done
# ./Script "ap ple" orange pear plum
“argument is ....ap ple″
“argument is ....orange″
“argument is ....pear″
Last edited by don570 on Wed 09 Nov 2011, 20:26, edited 2 times in total.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

new version folder_convert 1.2

#25 Post by don570 »

new version folder_convert 1.2

folder_convert has been fixed to show foreign languages properly.

I dumped the old yaf-splash and now use xdialog


______________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

dejan script

#26 Post by don570 »

Here's a script based on dejan's work.
It allows sed command to work on text that has
whitespace .

Code: Select all

#!/bin/sh
FIND="/ap ple/" 
ADD="/root/" 
echo "/ap ple/spot" |  sed  's:^'"$FIND"':'"$ADD"':' 

The terminal output is


# ./Script
/root/spot


_________________________________________________

Here's a script I wrote to
study positional characters i.e number of inputs --> $#
and to study exit status ---> $?

Code: Select all

#!/bin/bash
echo number of positional characters = $#

until [ -z "$1" ]  # Until all parameters used up . . .
do
echo -n "$1 "
shift
done
echo               # Extra line feed.
echo "$?"          # Determine exit status
if [ -z "$0" ] ; then
echo 
else
echo "$?"
echo "$0"
echo "$?"
fi
exit 0

# ./script a b c
number of positional characters = 3
a b c
0
1
./script
0

_______________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#27 Post by don570 »

Here's a script I found to do simple calculations

Code: Select all

#!/bin/bash
# Simple linux bash calculator 
echo "Enter input:" 
read userinput
echo "Result with 2 digits after decimal point:"
echo "scale=2; ${userinput}" | bc 
echo "Result with 10 digits after decimal point:"
echo "scale=10; ${userinput}" | bc 
echo "Result as rounded integer:"
echo $userinput | bc 
...and the terminal output.
# ./script
Enter input:
2+2
Result with 2 digits after decimal point:
4
Result with 10 digits after decimal point:
4
Result as rounded integer:
4
# ./script
Enter input:
2*8
Result with 2 digits after decimal point:
16
Result with 10 digits after decimal point:
16
Result as rounded integer:
16
# ./script
Enter input:
8/4
Result with 2 digits after decimal point:
2.00
Result with 10 digits after decimal point:
2.0000000000
Result as rounded integer:
2

____________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#28 Post by don570 »

Here's a script I found that does renaming(recursively)
of filenames that have whitespace .

Code: Select all

#!/bin/sh

# This bash script will locate and replace spaces
# in the filenames
DIR="."
# Controlling a loop with bash read command by redirecting STDOUT as
# a STDIN to while loop
# find will not truncate filenames containing spaces
find $DIR -type f | while read file; do
# using POSIX class [:space:] to find space in the filename
if [[ "$file" = *[[:space:]]* ]]; then
# substitute space with "_" character and consequently rename the file
mv "$file" `echo $file | tr ' ' '_'`
fi;
# end of while loop
done 
_____________________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#29 Post by don570 »

French German Spanish Finnish Italian Portugese Dutch
languages now supported

More languages are now supported by conversion_audio
thanks to

Béèm
ferro10n

Instructions to help in conversion effort are here
http://www.murga-linux.com/puppy/viewtopic.php?t=72856

_________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#30 Post by don570 »

Here I tested a new way of inputing variable values
using curly brackets.
Also there is a line in the script to
experiment with the test command ---> [
which is the square bracket. The output is zero
because 5 does not equal 9. The terminal output shows
this outcome.

Code: Select all

#!/bin/sh

FILENAME=$1
EXTENSION=$2
echo $@
[ 5 != 9 ]
echo $?
aplay /root/puppy-reference/audio/${FILENAME}${EXTENSION}
exit 0
Here's the terminal output. Note that there is two inputs
2barks and the extension .wav

Code: Select all

# ./script 2barks .wav
2barks .wav
0
Playing WAVE '/root/puppy-reference/audio/2barks.wav' 
: Signed 16 bit Little Endian, Rate 8000 Hz, Mono

________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#31 Post by don570 »

new version of conversion audio - version 1.5

Two improvements

1) I estimate the conversion time for the user,
however this probably won't be accurate if you have a slow machine

2) I pop a window up to show the conversion so it won't be
such a mystery!


Note: the foreign translations had to be changed as well.
______________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

new version 1.7

#32 Post by don570 »

new version 1.7

opens and converts more audio formats

such as flac and wma

Conversion time is approximate. I give the time needed
assuming the user has a fast machine.

____________________________________________

rmcellig
Posts: 965
Joined: Sat 19 Nov 2011, 15:18
Location: Ottawa Ontario Canada
Contact:

#33 Post by rmcellig »

don570

You mention that pmusic can convert multiple wav files to mp3. How do you go about doing this using pmusic?

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#34 Post by don570 »

It's shinobar's ffconvert that will convert an entire folder

and gnac does as well (but it requires gstreamer I believe,
That's why Jemimah uses it in Saluki)


I wrote a script too

folder_convert-1.2.pet

________________________________________________

rmcellig
Posts: 965
Joined: Sat 19 Nov 2011, 15:18
Location: Ottawa Ontario Canada
Contact:

#35 Post by rmcellig »

I used ffconvert to convert a folder of wav files but I don't think ffconvert can do sub folders as well. Maybe I'm wrong?

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#36 Post by don570 »

I don't think my script does sub-folders as well. That
takes a real expert.

If you're serious about doing this, then use Jemimah's Saluki or
Fluppy. They use GNAC which is written by pros.

________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#37 Post by don570 »

-new version of conversion audio 1.8
corrects for white space in file name ( thanks to RSH for
pointing this out)

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#38 Post by don570 »

Please test.

I've finished converting my audio tools to gettext .

Folder convert will convert a folder of wav files to mp3 and delete the
wav files as an option.

Also there are four scripts inside conversion_audio (/usr/local/bin/):

conversion_fast --> converts flac to wav
conversion_ universal --> converts ogg and wma to wav
conversion_wav ---> convert mp3 to wav
conversion_mp3 ----> convert wav to mp3

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#39 Post by don570 »

I've finished testing and I've posted on first page.

I found that tahr pup doesn't have ffmpeg installed so I made a simple
change.

For people doing localization work, note that there are several scripts.

________________________________________________________

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#40 Post by don570 »

New version Conversion-audio 2.4
and folder conversion 1.3

- Italian tranlation.

-It now convert many sound formats to wav.

_________________________________________-

Post Reply