Finder - Search and show folders

Hi guys,
I’m an italian user. So, sorry for my bad english.

I wrote AppleScript to find, thanks to dialog box, folders by entered name in first opened window, but I don’t know how can I hide folders without specific string and visualize folders with string.

Can you help me?

Thanks a lot


try
	tell application "Finder" to set the source_folder to (folder of the front window) as alias
on error -- no open folder windows
	set the source_folder to path to desktop folder as alias
end try

set contatore to "0"

repeat
	display dialog "Inserisci la stringa di testo da cercare:" default answer "" buttons {"Annulla", "OK"} default button 2
	set the search_string to the text returned of the result
	if the search_string is not "" then exit repeat
end repeat

set the item_list to list folder source_folder without invisibles
set source_folder to source_folder as string
repeat with i from 1 to number of items in the item_list
	set this_item to item i of the item_list
	set this_item to (source_folder & this_item) as alias
	set this_info to info for this_item
	set the current_name to the name of this_info
	if the current_name contains the search_string then
		set contatore to contatore + 1
		-- Routine di visualizzazione
		-- set this_item to not visible
		-- set end of item_list to current_name as list
		set this_item to false
		beep
	end if
end repeat

tell application "Finder" to display dialog "Sono state trovate " & contatore & " cartelle" buttons {"OK"} default button 1


Model: G5
AppleScript: 2.1.1
Browser: Firefox 1.5.0.12
Operating System: Mac OS X (10.4)

Ciao Luca.

Bienvenuto a MacScripter

Although it’s not recommended to make folders (in)visble with the visible property,
(invisible items starts with a dot in their names) it’s possible.
The Finder is not able to do it, but System Events can.
To apply the changes it’s necessary to restart the Finder

tell application "Finder" to set the source_folder to insertion location as alias
repeat
	set search_string to text returned of (display dialog "Inserisci la stringa di testo da cercare:" default answer "" buttons {"Annulla", "OK"} default button 2)
	if search_string is not "" then exit repeat
end repeat

tell application "System Events"
	set visible of folders of source_folder whose name contains search_string to true
	set visible of folders of source_folder whose name does not contain search_string to false
	set contatore to count (folders of source_folder whose name contains search_string)
end tell

tell application "Finder"
	quit
	delay 1
	launch
	open source_folder
	display dialog (("Sono state trovate " & contatore as string) & " cartelle") buttons {"OK"} default button 1
end tell

PS: next time please post into the OS X forum, this one is actually for OS 9

Moved to OS X forum.