[multimedia] Translate metaflac-field2field.sh
This commit is contained in:
parent
6d5f636bc9
commit
cea79af10f
|
@ -18,32 +18,39 @@
|
|||
|
||||
print_usage()
|
||||
{
|
||||
echo "Utilisation :"
|
||||
echo "Usage:"
|
||||
echo " $0 <ACTION> <SRC_FIELD> <DST_FIELD> <FILE.flac> [ <FILE2.flac> [...] ]"
|
||||
echo "ACTION : copy | move | rmcopy | mvcopy"
|
||||
echo " copy : chaque occurrence de SRC_FIELD est dupliquée pour créer une occurrence de DST_FIELD ; toutes les occurrences existantes de SRC_FIELD et de DST_FIELD sont conservées."
|
||||
echo " move : chaque occurrence de SRC_FIELD est déplacée pour créer une occurrence de DST_FIELD ; les occurrences existantes de DST_FIELD sont conservées."
|
||||
echo " rmcopy : les occurrences existantes de DST_FIELD sont supprimées, puis chaque occurrence de SRC_FIELD est dupliquée pour créer une occurrence de DST_FIELD ; les occurrences de SRC_FIELD sont conservées."
|
||||
echo " rmmove : les occurrences existantes de DST_FIELD sont supprimées, puis chaque occurrence de SRC_FIELD est déplacée pour créer une occurrence de DST_FIELD."
|
||||
echo "<ACTION> : copy | move | rmcopy | mvcopy"
|
||||
echo " copy: each occurrence of SRC_FIELD is duplicated to create an occurrence of"
|
||||
echo " DST_FIELD; all the existing occurrences of SRC_FIELD and DST_FIELD are"
|
||||
echo " kept."
|
||||
echo " move: each occurrence of SRC_FIELD is moved to create an occurrence of"
|
||||
echo " DST_FIELD; the existing occurrences of DST_FIELD are kept."
|
||||
echo " rmcopy: the existing occurrences of DST_FIELD are deleted, then each"
|
||||
echo " occurrence of SRC_FIELD is duplicated to create an occurrence"
|
||||
echo " of DST_FIELD; the occurrences of SRC_FIELD are kept."
|
||||
echo " rmmove: the existing occurrences of DST_FIELD are deleted, then each"
|
||||
echo " occurrence of SRC_FIELD is moved to create an occurrence of"
|
||||
echo " DST_FIELD."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Bon nombre d'arguments ?
|
||||
# Right number of arguments?
|
||||
if [ $# -lt 4 ] ; then
|
||||
echo "Mauvais nombre d'arguments !"
|
||||
echo "Wrong number of arguments!"
|
||||
print_usage
|
||||
fi
|
||||
|
||||
ACTION=$1
|
||||
shift
|
||||
|
||||
# Type d'action connue ?
|
||||
# Known action type?
|
||||
case $ACTION in
|
||||
copy) ;;
|
||||
move) ;;
|
||||
rmcopy) ;;
|
||||
rmmove) ;;
|
||||
*) echo "Action inconnue !" ; print_usage ;;
|
||||
*) echo "Action unknown \"$ACTION\"!" ; print_usage ;;
|
||||
esac
|
||||
|
||||
SRC_FIELD=$1
|
||||
|
@ -51,25 +58,27 @@ shift
|
|||
DST_FIELD=$1
|
||||
shift
|
||||
|
||||
echo "Champ source : $SRC_FIELD"
|
||||
echo "Champ destination : $DST_FIELD"
|
||||
echo "Action : $ACTION"
|
||||
echo "Source field: $SRC_FIELD"
|
||||
echo "Destination field: $DST_FIELD"
|
||||
echo "Action: $ACTION"
|
||||
|
||||
echo "Traitement des fichiers..."
|
||||
echo "Processing files..."
|
||||
|
||||
if echo $ACTION | egrep '^rm' >/dev/null ; then
|
||||
echo "Suppression du champ $DST_FIELD sur tous les fichiers..."
|
||||
echo "Deleting field $DST_FIELD on each file..."
|
||||
metaflac --remove-tag=$DST_FIELD "$@"
|
||||
fi
|
||||
|
||||
for file in "$@" ; do
|
||||
echo "Fichier : $file"
|
||||
echo "File: $file"
|
||||
metaflac --show-tag=$SRC_FIELD "$file" | sed 's/^[A-Z]\+=//' | while read c1 ; do
|
||||
metaflac --set-tag=$DST_FIELD="$c1" "$file"
|
||||
done
|
||||
done
|
||||
|
||||
if echo $ACTION | egrep 'move$' >/dev/null ; then
|
||||
echo "Suppression du champ $SRC_FIELD sur tous les fichiers..."
|
||||
echo "Deleting $SRC_FIELD on each file..."
|
||||
metaflac --remove-tag=$SRC_FIELD "$@"
|
||||
fi
|
||||
|
||||
# vim: expandtab!:ts=2
|
||||
|
|
Loading…
Reference in New Issue