Grazie, con questo script sono comunque riuscito a fare quello che volevo :-D