This forum has been archived. All content is frozen. Please use KDE Discuss instead.

ape2flac - converting *.ape to *.flac

Tags: None
(comma "," separated)
Wujek_Bogdan
Registered Member
Posts
11
Karma
0
maby somone need it:
it's simple script converting ape files into flac. i've found it on russian forum :)

1) create new txt file eg. ape2flac.sh
2) copy script
3) save file :)
3) copy ape2flac.sh into dir/where/you/have/ape/files
4) type sh ape2flac.sh
5) that's it!

Code: Select all
#!/bin/sh

#
# @(#) ape2flac 0.1b 23/01/2007 by BaBL
# Checking for mac & flac
# Checking for input directory
#
# @(#) ape2flac 0.1a 14/01/2007 by BaBL
# Fixed a bug identifying filenames with more then one "." symbol
#
# @(#) ape2flac 0.1 26/09/2003 by Peo Karlsson
#
# Recursively convert APE-files to FLAC.
# Directory recursion adapted from the 'tree' script by Jordi Sanfeliu (see below).
#

#
# @(#) tree 1.1 30/11/1995 by Jordi Sanfeliu (mikaku@fiwix.org)
#
# Initial version: 1.0 30/11/95
# Next version : 1.1 24/02/97 Now, with symbolic links
#

# which extension to look for when browsing the tree

myext="ape"
declare -a prog_needed=(mac flac)

search () {
xx=0
for dir in *
do
if [ -f "$dir" ]; then
ext=`echo "$dir" | sed -ne 's!^.*\.!!p' | tr '[:upper:]' '[:lower:]'` &> /dev/null
base=`echo "$dir" | sed -e 's!\.[^.]*$!!'` &> /dev/null
if [ "$ext" = "$myext" ]; then
echo -n ".";
mac "$dir" - -d | flac - -o "$base.flac" &> /dev/null
rm -f "$dir" &> /dev/null
xx=`expr $xx + 1`
numfiles=`expr $numfiles + 1`
fi
else
if [ $xx > 0 ]; then
echo " -> [$xx files converted]"
xx=0
fi
fi

if [ -d "$dir" ]; then
zz=0
while [ $zz != $deep ]
do
echo -n "| "
zz=`expr $zz + 1`

done
if [ -L "$dir" ]; then
echo -n "+---$dir" `ls -l $dir | sed 's/^.*'$dir' //'`
else
echo -n "+---$dir"
if cd "$dir"; then
deep=`expr $deep + 1`
search
numdirs=`expr $numdirs + 1`
fi
fi
fi
done
cd ..
if [ "$deep" ]; then
swfi=1
fi
deep=`expr $deep - 1`
}

if [ $# = 0 ]; then
cd `pwd`
elif [ -e "$1" ]; then
cd $1
else
echo "Path \"$1\" not found"
exit 0
fi

for i in ${prog_needed[@]}
do
echo -n "Checking for $i..... "
if which "$i" &> /dev/null; then
echo "Yes"
else
echo "No"
echo "Programm $i is not installed. Please install $i first"
exit 0
fi
done

echo
echo "ape2flac 0.1b"
echo
echo "bash script to convert files compressed by Monkey's Audio into FLAC files."
echo
echo "Converting all files in directory = `pwd` and recurse indefinitely."
echo
swfi=0
deep=0
numdirs=0
numfiles=0
zz=0
xx=0

while [ "$swfi" != 1 ]
do
search
done
echo
echo "Summary:"
echo
echo "Total directories = $numdirs"
echo "Total files converted = $numfiles"
echo
exit 0
vallareviv
Registered Member
Posts
2
Karma
0
I did it and it's working :)

All you need is install mac program first ;]
User avatar
cylverbak
Registered Member
Posts
88
Karma
0
OS
What is the file name of the mac program that needs installing? I'm running debian and can't find anything in the repositories that looks applicable.

Thanks.
vallareviv
Registered Member
Posts
2
Karma
0
mac - Monkey's Audio Codec console player, it seems that for debian you can download it from here:

http://www.debian-multimedia.org/dists/ ... -audio.php

I hope it helps :)
User avatar
cylverbak
Registered Member
Posts
88
Karma
0
OS
Thanks vallareviv, that's got it. I needed the i386 version rather than the alpha version and once I got that sorted out things are working beautifully.

Thanks Wujek_Bogdan for the script. One more step towards windows-free :D

Last edited by cylverbak on Sun Oct 28, 2007 1:53 pm, edited 1 time in total.
coveka
Registered Member
Posts
1
Karma
0
You can use Konsole to convert files with this command:
mac inputfile.ape outputfile.flac -d
User avatar
dangle_wtf
Moderator
Posts
1252
Karma
0
well no kidding, but did you look at the script?


"There are two theories to arguing with women. Neither one works."
.
If men could get pregnant, we'd learn the true meaning of "screaming nancyboy wuss"


Bookmarks



Who is online

Registered users: Bing [Bot], blue_bullet, Google [Bot], Yahoo [Bot]