All pastes #584713 Raw Edit

mpilator

public shellscript v1 · immutable
·published 2007-06-22 22:06 UTC
rendered paste body
#!/bin/bashE_ERR_ARG=65if	(( "$#" <  1 )) then	 echo "----------------------------------------"	 echo "Utilizzo: `basename $0` [-r] collezione "	 echo "          -r genera una playlist casuale"	 echo "----------------------------------------"	 exit $E_ERR_ARGelif	(( "$#" == 2 )) then	 path="$2" else	 path="$1"fiechoif	[ ! -d "$path" ] && [ ! -w "$path" ] then	 echo "Controlla il percorso"	 exit $E_ERR_ARGfipath=${path%/}echo "Cerco i file.mp3 in \"$path/\" ricorsivamente"find -P "$path" -name *.mp3 > "$path"/playlistecho "Scrivo i file.mp3 in \"$path/playlist\""echo "end" >> "$path"/playlistif	[ "$1" == "-r" ] then	 echo "Randomizzo la playlist"	 exec < "$path"/playlist	 read song	 number=1	 while	[ "$song" != "end" ]	  do	 array[$number]=$song		 read song	 	 let "number++"	  done	 count=1	 if [ -e "$path"/rand_list ]; then rm "$path"/rand_list; fi	 touch "$path"/rand_list	 while	[ "$count" -le "$number" ]	  do	 let "numero = $RANDOM % $number+1"		 if 	[ casual[$numero] != 1 ]		  then	 echo ${array[$numero]} >> "$path"/rand_list			 casual[$numero]=1			 let "count+=1"		 fi	 done	 echo; echo	 echo "---------------------------------------------------------------------------------------"	 echo "Playlist casuale presente in \"$path/rand_list (/playlist per la lista ordinata)\""	 echo "---------------------------------------------------------------------------------------"	 echo else	 echo; echo	 echo "-------------------------------------"	 echo "Playlist presente in \"$path/playlist\""	 echo "-------------------------------------"	 echo fiexit 0