Συντονιστής: konnn
################################## wma2mp3.sh ##################################
# Author : Karapanagiotis Pantelis #
# Released On : Tuesday 07 July 2009 #
# Version : 0.2 #
# Desription : Converts all wma files in the current folder to mp3 ones. It #
# is able to convert all files, independently of the characters #
# contained in their names. Track tags are preserved after the #
# conversion process. #
# Dependencies : This script depends on ffmpeg to recode the original wma to #
# a mp3 one. You need to have an ffmpeg installation with mp3 #
# encoding and the mp3lame library enabled. The line commands #
# for enabling these options during configuration of the #
# installation are --enable-libmp3lame and --enable-encoder=mp3.#
# The script will otherwise not work. For more information check#
# with the ffmpeg website. It also depends on python and #
# specifically on the mutagen module. Install in debian-like #
# enviroments with sudo apt-get install python3 #
# You also need to have the accompanying python scrint that #
# copies tags from the original files. The tagcop.py is also #
# published under GNU License #
# Usage : In order to avoid copying the file to every folder you want to#
# use it, do the following: #
# sudo cp wma2mp3.sh /usr/local/bin/wma2mp3 #
# sudo cp tagcop.py /usr/local/bin/tagcop #
# cd /usr/local/bin #
# sudo chmod +x tagcop #
# sudo chmod +x wma2mp3 #
# Then cp to the folder you want to use the script and call #
# wma2mp3 #
# TODO : >>Check if user aborted some conversions >>Let user choose #
# bitrare. >>Enable more conversions #
# COPYRIGHT : This program is free software: you can redistribute it and/or #
# modify it under the terms of the GNU General Public License as#
# published by the Free Software Foundation, either version 3 of#
# the License, or (at your option) any later version. This #
# program is distributed in the hope that it will be useful, but#
# WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
################################################################################
#!/bin/bash
echo Executing $(basename $0)
#Variable Declarations
converted=0
found=0
#Converting wma to mp3
for i in *.wma; do
found=$(expr $found + 1)
mv "$i" temp.wma
ffmpeg -i temp.wma -y -qscale 1 -ab 192k -ar 48000 -ac 2 temp.mp3
if [ $? -eq 0 ]; then
echo "$i" successfully converted to "${i%.wma}.mp3"
converted=$(expr $converted + 1)
else
echo failed recoding "$i"
fi
mv temp.mp3 "${i%.wma}.mp3"
mv temp.wma "$i"
#Copying Tags from original files
tagcop "$i" "${i%.wma}.mp3"
done
#Removing temporary files
rm -r temp.wav
echo $converted\\$found files successfully converted
echo Would you like to remove the files with wma extension? [y\\n]?
#Remove wma file if y is given
while read inputline; do
in="$inputline"
if [ $in == y ] || [ $in = n ]; then
if [ $in == y ]; then
echo Removing all files with wma extension:
find $pwd -name \*.wma -print -delete
fi
break
else
echo Unexpected input sequence. Pleaze try again: [y\\n]?
fi
done
echo Exiting $(basename $0)
#!/usr/bin/env python
################################## tagcop.py ###################################
# Author : Karapanagiotis Pantelis #
# Released On : Tuesday 07 July 2009 #
# Version : 0.1.1 #
# Desription : Copies tags from a wma to a mp3 audio file. #
# Dependencies : Uses mutagen module #
# Usage : Call with tagcop.py filename.wma filename.mp3 #
# COPYRIGHT : This program is free software: you can redistribute it and/or #
# modify it under the terms of the GNU General Public License as#
# published by the Free Software Foundation, either version 3 of#
# the License, or (at your option) any later version. This #
# program is distributed in the hope that it will be useful, but#
# WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
################################################################################
#Loading Modules
from mutagen.asf import ASF
from mutagen.mp3 import MP3
from mutagen.id3 import ID3, TIT2, TPE1, TALB, TCOM, TRCK, TYER, TCON
from sys import argv, exit
import os
#Checking Command Line Arguments
if len(argv) != 3:
print("Wrong number of command line arguments. Two arguments must be used.")
exit()
#Checking File Extensions
if argv[1][-3:] != "wma":
print("First argument must be of wma type")
exit()
if argv[2][-3:] != "mp3":
print("Second argument must be of mp3 type")
exit()
wma_fname = os.getcwd() + '/' + argv[1]
mp3_fname = os.getcwd() + '/' + argv[2]
wma = ASF(wma_fname)
mp3 = MP3(mp3_fname)
#Copying Tags
mp3['TRCK'] = TRCK(encoding=3, text=wma['WM/TrackNumber'])
mp3['TIT2'] = TIT2(encoding=3, text=wma['Title'])
mp3['TPE1'] = TPE1(encoding=3, text=wma['Author'])
mp3['TALB'] = TALB(encoding=3, text=wma['WM/AlbumTitle'])
mp3['TCOM'] = TCOM(encoding=3, text=wma['WM/Composer'])
mp3['TYER'] = TYER(encoding=3, text=wma['WM/Year'])
mp3['TCON'] = TCON(encoding=3, text=wma['WM/Genre'])
mp3.save()
Ntelispak έγραψε:...
Δυστυχώς υπάρχει ασυμβατότητα μεταξύ των tags των wma και των mp3 στο πεδίο των ειδών και δεν μπόρεσα να το κάνω να διατηρείται.
$ echo 45 μάστοροι κι 60 μαθητάδες | perl -ne 'while (/([0-9]+)/g) { push(@array, $1); }; print join(":",@array)."\n";'
45:60
$ echo 60 a b c 45 μια χαρά τα πάμε 90 80 | perl -ne 'while (/([0-9]+)/g) { push(@array, $1); }; print join(":",@array)."\n";'
60:45:90:80
$ echo 1+ 100--- πιανει και αριθμούς ανάμεσα σε άλλους χαρακτήρες. ====ουυυυ150=== | perl -ne 'while (/([0-9]+)/g) { push(@array, $1); }; print join(":",@array)."\n";'
1:100:150
malos έγραψε:
Υ.Γ. Εκτός από το man της sed, ξέρετε κάτι πιο ελληνικό , με παραδείγματα, που να με εισάγει μια ιδέα στη sed ;
head ΧΧΧ | grep CHO