I can't Believe that! It worked!... I only replaced the first occurence of "Folder" with "Cartella" (the second occurence I'm not allowed, I get an error message whereas "" are expected, but even if I put "Cartella" I still get the error) and it worked...!
I'm quite surprised though.. I don't know anything of programming language, however I always noticed that in Terminale for examples any names of folder is always translated by the terminal in English; so that If I drag and drop the folder "Immagini" for examples (the name that appears in the Finder, into the terminal window, it translate it into "Pictures". that's why when I do a script for example that call Rsync I have to specify the path in English. So I'have always thought that for programming anything I should have used the EN names..
By the way that was the case some OS ago... I had copied a similar script to yours to do the same some years ago (I don't remember though what version of the OSX was) and it worked the same but it used "Folder".. I would never ever thought that could be the problem!
Thank you very much indeed and Happy Easter! that was really an Easter egg.. :-))
Best
on run {input, parameters}
tell application "Finder"
repeat with anItem in input
if kind of anItem is "Cartella" then
set theFiles to (every file in entire contents of folder anItem)
repeat with afile in theFiles
set extension hidden of afile to true
end repeat
else
set extension hidden of anItem to true
end if
end repeat
end tell
return
end run