Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

canonballs

macrumors member
Original poster
Mar 8, 2009
36
0
I am rather late in going 10.5, so I'm just starting to deal with the peculiarities of this system that have been discussed quite a while ago.

For me, the biggest annoyance so far is the way 10.5 remembers or fails to remember folder view options. Apparently it will forget everything and select the currently default view option the next time you open a folder unless you have opened the View options panel (apple-J) and ticked the tiny "Always open in..." checkbox. That's fine for one or two folders, but can get really annoying for several thousand ones.

I have googled around for this and have found lots of complaints but no solutions. Of course, I may have missed quite a few things, so I apologize in advance and would be most appreciative if somebody could point me towards better answers.

Now I live under 10.5.6 and "Always open folders in a new window" preference. I like some folders to always open in, say, icon view and others, in, for the sake of argument, list view. Most of all, I like those folders dear to my heart to remember their layout settings, and this most emphatically includes view option. And, as I have mentioned, I don't like manually ticking thousands of checkboxes.

I wish there was a script that mandated a given view option for a specified subtree of the folder hierarchy. As I was about to despair looking for salvation I stumbled on a cryptic tip at the bottom of this excerpt from Sal Soghoian's book which suggests a way to set the permanent view option for all subfolders of a folder:

Code:
tell application "Finder" to set the current view of ¬
 the window of every folder of home to icon view

I tried it out and it worked. So I modified it to work recursively down the tree:

Code:
on recTrim(aFolder, aView)
	trim(aFolder, aView)
	tell application "Finder"
		set allSubfolders to (folders of aFolder)
	end tell
	repeat with nextFolder in allSubfolders
		recTrim(nextFolder, aView)
	end repeat
end recTrim

on trim(anotherFolder, anotherView)
	tell application "Finder"
		if anotherView = "icon view" then
			set the current view of the window of anotherFolder to icon view
		else if anotherView = "list view" then
			set the current view of the window of anotherFolder to list view
		else if anotherView = "column view" then
			set the current view of the window of anotherFolder to column view
		else if anotherView = "(cover) flow view" then
			set the current view of the window of anotherFolder to flow view
		end if
	end tell
end trim

tell application "Finder"
	set selectedFolder to (choose folder with prompt "Choose the folder to unify views")
	set viewList to {"icon view", "list view", "column view", "(cover) flow view"}
	set chosenView to choose from list viewList OK button name "Set" with prompt "Set \"" & (displayed name of selectedFolder) & "\" together with all of its sub-, subsub- etc. -folders to always open in"
end tell
if chosenView is false then
	--cancelled
else
	--OKayed
	set viewName to chosenView as string
	recTrim(selectedFolder, viewName)
	display dialog "Done!" buttons {"Quit"}
end if

The script appears to mostly give the desired result but it has an unexpected side-effect: As the script starts the syslogd process goes berserk (about 120% CPU) and writes loads of stuff (like 1.5GB in 15 or so minutes) to

Code:
/private/var/log/system.log

It does not stop after the script terminates and the only way I found to stop it is sudo-kill. (It starts anew after a while but does so in its usual benign quality.) Now I have seen discussions of syslogd eruptions in 10.5 for no apparent reasons but looking at the script itself, whatever it does, it really ought not to be triggering that much low-level havoc.

I would be very curious to know if this is a feature of my individual installation or if this happens on your device as well. Mind you, I am anything but an experienced scripter, so I would greatly appreciate it if somebody tells me what I am doing wrong or stupid.

Back to View options, I think I have failed to understand the logic 10.5 follows in assigning View options to individual windows or folders but the following appears to be a useful approximation:

If a window to a folder is open then telling "set the current view" to either that Finder window or the window of the corresponding folder in the one-off, forgettable way. However, if that same folder is closed then setting the current view of "the window of" that folder talks to all the potential windows onto that that could be and tends to stick.

So I thought I'd write a script that sets the view option for the folder in the frontmost window forever (that's what I would like to happen when I press, say, apple-2):

Code:
tell application "Finder"
	set targetFolder to (target of the front Finder window) as alias
	close the front Finder window
	set the current view of the window of targetFolder to list view
	make new Finder window to targetFolder
end tell

This achieves the desired result: the folder starts to behave in the expected way right away even though the tick in the checbox of the View options panel may take some time to appear (the next time you apple-J or the time after several next ones). On my system the execution is sufficiently close to instantaneous to not make it annoying. And no, the shorter script does not awaken the beast in syslogd.

The one-off forgettable view option change is achieved with

Code:
tell application "Finder" to set the current view of the front Finder window to list view

And then I found the remarkable application Spark that lets me associate scripts to keystroke combinations (it's like Xkeys today—pure delight! and free!) and even lets you override those Finder shortcuts such as apple-3 that I could not get at through

Code:
System preferences —> Keyboard & Mouse —> Keyboard shortcuts,

so now when I press apple-1 I set icon view permanently and I can use apple-option-1 for a one-off view option change.

Let me stress again that the above describes the situation when "Always open folders in a new window" Finder preference is in force. I have not and probably will not investigate what happens without it.

How does the Finder remember what a folder's permanent view option if any is? The logical place to remember that appears to be .DS_Store of the folder (which is exactly what makes me suspect it's stored elsewhere). From reading here and there on the 'net I gathered that the format of .DS_Store is undocumented and that if anyone has reverse-engineered it they are keeping that knowledge to themselves (I remember that guys from Rixstep were once about to have a crack at .DS_Store). Am I quite right about this or has public knowledge about .DS_Store improved recently?

I would be grateful for any answers, advice, comments or pointers.
 
Thanks for posting this. It looks like it is exactly what I was looking for. I too am late in moving up to Leopard; so far, I'm very happy about that. I hope that Snow Leopard is better. I'll give this a try as soon as I can.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.