Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Fixed version to match all the different kind of files selected' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fixed version to match all the different kind of files selected
Authored by: Lutin on Apr 19, '06 02:01:19AM
This idea is pure genius. I wish I had it earlier, It would have saved me a lot of time.

Here is my own adapatation.
- It now rely on the kind of a file, not its extension (then, if you have img1.jpg and img2.JPG, it'll work properly).
- If several files are selected, the final selection will match all the kind of file present in the inital selection (example: if you select text1.txt, archive.gzip and folder1, it'll select all the txt and gzip files and the folders).


-- In column mode, if only folders are selected, it doesn't work as expected
-- The selection is only the last folder of the window.
-- Works fine in other view mode
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
	--problem is a window can be open but out of focus
	beep
end try

tell application "Finder"
	set kindList to {}
	set toselectList to {}
	
	-- Get the current selection
	set selectionList to {} & selection as list
	
	-- Be sure the selection isn't empty
	set selectedCount to count items in selectionList
	if selectedCount > 0 then
		
		-- Get all kind of files selected
		repeat with list_item in selectionList
			if (kind of list_item) is not in kindList then
				set end of kindList to kind of list_item
			end if
			
		end repeat
		
		-- Get all the elements of the folder
		set allList to (every item of folder source_folder)
		
		-- Add the files matching to kind selected to the list allList
		repeat with file_item in allList
			if kind of file_item is in kindList then
				set end of toselectList to file_item
			end if
		end repeat
		
		-- Select the files
		select (every item of toselectList)
	end if
end tell

There is one bug I couldn't fix: If you are in column view mode, if only folders are selected, it doesn't work as expected.
The final selection is only the last folder of the window.
It works fine in other view mode.

If anyone as any idea of how to fix this, please tell me.

[ Reply to This | # ]
Fixed version to match all the different kind of files selected
Authored by: ret on Apr 19, '06 02:38:43AM

Haven't got the answer to your bug, but just wanted to say the concept and your solution are terrific.

Thanks

cheers
RET

---
perl -e 'require Signature.pm; srand; printf STDOUT "%s\n", $Signature[rand @Signature];'



[ Reply to This | # ]
work around for the bug
Authored by: mzs on May 26, '06 06:53:36AM
There is a work-around foir the column view bug in the hint: Select files in Finder from Terminal. Scroll down for the comment titled:

  fix for column view bug

Is there a way to link to individual comments at macosxhints?

[ Reply to This | # ]