Amarok Script to Pana Script converter

I use Pana now in favour of Amarok 1.4. Pana is under active development and includes a fix for the cover fetcher that stopped working some time ago.

The next step was to find a way to port the amarok scripts over to Pana. This is easily acheived ( for replay_gain ) anyway with this script:

Source: http://air.elementfx.com/phpBB3/viewtopic.php?f=5&t=3#p3

#! /bin/bash
FILE=$1
FILENAME=`echo ${FILE##*/}`
mkdirerr=$(mktemp)
mkdir $FILENAME".tmp" 2> $mkdirerr
if [ -n "`cat $mkdirerr`" ]; then
cat $mkdirerr
exit
fi
cd $FILENAME".tmp"
echo "Extracting files to $FILENAME.tmp/ ..."
tar jxvf $FILE &> /dev/null

currentdir=`pwd`

for (( i=0 ; $i < `find . -depth -type d | wc -l` ; i=$(( $i+1 )) ));
do
directory[$i]=`find . -depth -type d | head -$(( $i+1 )) | tail -1`
done


for (( i=0 ; $i < ${#directory[@]} ; i=$(( $i+1 )) )); do
cd ${directory[$i]}
for file in `find . -depth -maxdepth 1 -type f ` ; do
echo "Changing "$file
NEWNAME=`echo $file | sed 's/amarok/pana/g'`

sed -i 's/amarok/pana/g' $file
sed -i 's/Amarok/Pana/g' $file

if [ "$file" != "$NEWNAME" ]; then
echo "Renaming file $file to $NEWNAME"
mv $file $NEWNAME
fi
done

cd $currentdir
if [ -z "`echo ${directory[$i]%/*} | grep 'amarok'`" ] && [ "${directory[$i]}" != "." ]; then

NEWDIRNAME=`echo ${directory[$i]##*/}`
NEWDIRNAME=`echo ${NEWDIRNAME} | sed 's/amarok/pana/g'`
NEWDIRNAME=`echo ${NEWDIRNAME} | sed 's/Amarok/Pana/g'`
NEWDIRNAME=${directory[$i]%/*}"/"$NEWDIRNAME
echo "Renaming directory ${directory[$i]} to ${NEWDIRNAME}"
mv ${directory[$i]} ${NEWDIRNAME}
fi
echo "Finished folder ${directory[$i]}"
echo ""
done




NEWFILENAME=$FILENAME
NEWFILENAME=`echo ${NEWFILENAME} | sed 's/amarok/pana/g'`
NEWFILENAME=`echo ${NEWFILENAME} | sed 's/Amarok/Pana/g'`

echo "Recompressing files into $NEWFILENAME"
tar jcvf $NEWFILENAME `ls` &> /dev/null
mv $NEWFILENAME ..
cd ..

echo "rm -f -r ${FILENAME}.tmp/"
# rm -f -r "${FILENAME}.tmp/"


Once you have done all this, then just import the new Pana version of your script using the Pana Script Manager.

Comments

Popular posts from this blog

Automatically mount NVME volumes in AWS EC2 on Windows with Cloudformation and Powershell Userdata

Extending the AD Schema on Samba4 - Part 2

Python + inotify = Pyinotify [ how to watch folders for file activity ]