#!/bin/bash ##################################### # DESCRIPTION # StreamManager: script which delete non-wanted songs # recorded by streamripper and which create a blank file # with the same name in order to not re-record it. # ##################################### # INFO # Author : ZeBob - zebob.m AT gmail DOT com # Licence : GNU GPL # Dependency : zenity # History : 22.01.2006 : v0.1 # Install # Put in ~/.gnome2/nautilus-scripts/ # In a console : # chmod u+x ~/.gnome2/nautilus-scripts/streammanager # ###################################### # Use # Select files to delete in Nautilus or just run the script # to list all music files in the folder # Todo # More localization # Add a zenity progress dialog when loading files # Known bugs # Don't work for file beginning with '-' # ###################################### ###################################### # TRADUCTIONS (todo) ###################################### ###### English ##### titre="StreamManager "$version"" choisir="Choose the files you want to delete and replace by blank files." colonne="Files" efface=" has been deleted and replaced." case $LANG in ###### French ##### fr* ) titre="StreamManager "$version"" choisir="Choississez les fichiers que vous voulez supprimer et remplacer par des versions vides." colonne="Fichiers" efface=" a été supprimé et remplacé." ###### Add others ##### esac ################################################################# # VARIABLES # ################################################################# liste= #array with selected files or the folder where the script is run liste_choisie= #array with selected files after the zenity dialog fichier_a_supprimer= #variable with the current file to delete resultat= #variable which contains the results sm_dir="$HOME/.Trash/streammanager" #the path of the deleted files ################################################################# # PROGRAM # ################################################################# if [ $# -eq 0 ]; then #check if there is files in command line parameter, if not select all the file in the folder for fichier in * do #check if the file is: writeable, ogg or mp3 if [ -w "${fichier}" ]; then if [ "$(file -bi "${fichier}")" == "application/ogg" \ -o "$(file -bi "${fichier}")" == "audio/mpeg" ]; then liste=("${liste[@]}" "TRUE" "${fichier}") #then put all files in an array fi fi done else for fichier do if [ -w "${fichier}" ]; then #same as above if [ "$(file -bi "${fichier}")" == "application/ogg" \ -o "$(file -bi "${fichier}")" == "audio/mpeg" ]; then liste=("${liste[@]}" "TRUE" "${fichier}") fi fi done fi #show a zenity dialog with files in order to choose which to delete liste_choisie=$(zenity --title="${titre}" --width=640 --height=480 --list --text="${choisir}" --checklist \ --separator=";" --column=" " --column="${colonne}" "${liste[@]:1}") if [ -n "${liste_choisie}" ]; then if [ ! -e $sm_dir ]; then #check if the streammanager folder exists in the trash mkdir $sm_dir elif [ ! -d $sm_dir ]; then rm $sm_dir mkdir $sm_dir fi IFS=";" for fichier_a_supprimer in ${liste_choisie[@]} do mv "${fichier_a_supprimer}" "${sm_dir}/${fichier_a_supprimer}" #move the file to trash touch "${fichier_a_supprimer}" #create a blank file with the same name resultat=("${resultat[@]}" "${fichier_a_supprimer}${efface}") done unset resultat[0] zenity --title="${titre}" --text="" --width=640 --height=480 --list --column="${colonne}" "${resultat[@]}" fi exit 0