Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #######################################################################################
- #Script Name :bigscript.sh
- #Description :Script to modify the names of the mp3 files
- #Author :Zuzanna Potrzebska
- #Email :zuzia__124@wp.pl
- #License :GPL
- #######################################################################################
- OPTION=0
- HEADER=""
- TITLE=""
- ARTIST=""
- ALBUM=""
- YEAR=""
- GENRE=""
- function main{
- echo "Hello, it’s an mp3 tag editor."
- echo "You can edit here all the names of mp3 files of the chosen directory."
- echo -e -n "Write a path to your files (default: 'pwd'):"
- read PATH
- #echo "Here are all files with mp3 extension from your directory:"
- #echo
- #find $PATH type -f "*mp3"
- echo "What tags do you need in your file name? Select Yes/No." #wybór tagów, które mają znaleźć się w nowej nazwie pliku
- echo "1 - Header"
- select yn in "Yes" "No"; do
- case $yn in
- Yes ) AHEADER="yes";;
- No ) AHEADER="";;
- * ) echo "Please answer yes or no";;
- esac
- done;;
- echo "2 - Title"
- select yn in "Yes" "No"; do
- case $yn in
- Yes ) ATITLE="yes";;
- No ) ATITLE="";;
- * ) echo "Please answer yes or no";;
- esac
- done;;
- echo "3 - Artist" $ARTIST
- select yn in "Yes" "No"; do
- case $yn in
- Yes ) AARTIST="yes";;
- No ) AARTIST="";;
- * ) echo "Please answer yes or no";;
- esac
- done;;
- echo "4 - Album" $ALBUM
- select yn in "Yes" "No"; do
- case $yn in
- Yes ) AALBUM="yes";;
- No ) AALBUM="";;
- * ) echo "Please answer yes or no";;
- esac
- done;;
- echo "5 - Year of release" $YEAR
- select yn in "Yes" "No"; do
- case $yn in
- Yes ) AYEAR="yes";;
- No ) AYEAR="";;
- * ) echo "Please answer yes or no";;
- esac
- done;;
- echo "6 - Genre" $GENRE
- select yn in "Yes" "No"; do
- case $yn in
- Yes ) AGENRE="yes";;
- No ) AGENRE="";;
- * ) echo "Please answer yes or no";;
- esac
- done;;
- shopt -s nullglob
- for F in $PATH *.mp3; #pobranie kolejnych zaznaczonych wcześniej tagów
- do
- if [ -n "$AHEADER" ];
- then HEADER=$(easytag --show-tags header $F);
- fi
- if [ -n "$ATITLE" ];
- then TITLE=$(easytag --show-tags title $F);
- fi
- if [ -n "$AARTIST" ];
- then ARTIST=$(easytag --show-tags artist $F);
- fi
- if [ -n "$AALBUM" ];
- then ALBUM=$(easytag --show-tags album $F);
- fi
- if [ -n "$AYEAR" ];
- then YEAR=$(easytag --show-tags year $F);
- fi
- if [ -n "$AGENRE" ];
- then GENRE=$(easytag --show-tags genre $F);
- fi
- chmod 777 $F #dodanie dostępu w celu zmienienia nazwy
- NEWNAME=$($HEADER"-"$TITLE"-"$ARTIST"-"$ALBUM"-"$YEAR"-"$GENRE) #określenie, co będzie się w nazwie znajdować
- mv F $NEWNAME #ponowne nazwanie
- echo $NEWNAME
- done
- }
- while getopts ":hv" opt; do
- case ${opt} in
- h ) echo "help - First choose the path which in you want to change the names of the mp3 files; leter choose tags.";;
- v ) echo "version - 1.0 by Zuzanna Potrzebska";;
- \? ) echo "Invalid code - choose h, v or nothing";;
- esac
- done
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement