Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > CLI command for view options

CLI command for view options
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2002
Status: Offline
Reply With Quote
Mar 9, 2004, 08:24 AM
 
Is there a CLI command that I could include in my cron file which would globally set view option to icon, sort by name?
     
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Mar 9, 2004, 01:06 PM
 
You would need to create a shell script that calls an applescript (with the shell command osascript).

The essential part could look like:
Code:
osascript \ -e "set startfolder to POSIX file \"/\"" \ -e "tell application \"Finder\"" \ -e " set current view of container window of every folder of the entire contents of folder startfolder to icon view -e " set icon view options of container window of every folder of the entire contents of folder startfolder to arranged by name -e "end tell"
WARNING: This is untested, you might want to use another folder than / for your first tries.

-
     
Dedicated MacNNer
Join Date: Jul 2002
Location: Norway
Status: Offline
Reply With Quote
Mar 9, 2004, 04:53 PM
 
Is it possible to set it to "All Windows" mode for icons ?? This has been my no. 1 missing feature in Mac OS X ever !!!
Mac Pro 2 x 2.8 GHz Quad-Core, Nvidia GeForce 8800GT
     
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Mar 9, 2004, 05:15 PM
 
I am not sure what you mean by "All Windows" mode for icons. However the above script will set the windows of all existing subfolders of a specified folder to icon view. If you don't want to run it from a shell script or the terminal you can make a normal applescript doing this and start it manually, perhaps from the AppleScript menu item if you have it installed.

But if you look for a default mode for new windows you'll need to tell Apple because that can't be changed at the moment.

-
     
Dedicated MacNNer
Join Date: Jul 2001
Location: NC
Status: Offline
Reply With Quote
Mar 9, 2004, 11:13 PM
 
Hi Kenneth,
   The command to change the view to column view is:

defaults write com.apple.finder ComputerOptions -dict-add ComputerViewStyle clnv

Unfortunately, the last "word", clnv, is Apple's arbitrary abbreviation for "column view". Since I don't use icon view, I wouldn't know what the four letter abbreviation for that view is. Maybe it's icnv or just icon. You can find what yours is with:

defaults read com.apple.finder ComputerOptions ComputerViewStyle | grep ComputerViewStyle

If yours is already set to icon view, the above command should tell you the correct abbreviation. Otherwise, hopefully someone else will run the above command and post the correct abbreviation. The command for setting the sort criteria is similar:

defaults write com.apple.finder ComputerOptions -dict-add ComputerIconViewArrangeBy dnam

The file that stores these preferences is ~/Library/Preferences/com.apple.finder.plist. I hope that helps.
Gary
A computer scientist is someone who, when told to "Go to Hell", sees the
"go to", rather than the destination, as harmful.
     
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Mar 10, 2004, 12:12 AM
 
Oops, I was not completely right. Of course there's a setting in the Finder preferences (and has always been) to open new windows in column view instead of icon view. Why there's no option for list view must be Apple's secret.

-
     
Fresh-Faced Recruit
Join Date: Mar 2002
Status: Offline
Reply With Quote
Mar 10, 2004, 05:10 AM
 
Thanks for all the advice, but let me elaborate a little more. I looked at com.apple.finder and found ComputerViewStyle set for icnv and ComputericonViewArrangeBy set to dnam. Given these settings, I have the main directory/folder arranged in proper order, but if I open the applications folder, it has icons but not sorted by name. My frustration is caused by setting the proper display configuration for a folder only to have it lose the sort parameter for no apparent reason. This was my primary motivation for including a cron command nightly to correct this problem.
     
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Mar 10, 2004, 01:31 PM
 
Forget the Finder preferences, each folder's window has once created its own settings. And I told you above how to do what you want.

-
     
Dedicated MacNNer
Join Date: Jul 2002
Location: Norway
Status: Offline
Reply With Quote
Mar 11, 2004, 07:29 AM
 
Originally posted by Moonray:
I am not sure what you mean by "All Windows" mode for icons. However the above script will set the windows of all existing subfolders of a specified folder to icon view. If you don't want to run it from a shell script or the terminal you can make a normal applescript doing this and start it manually, perhaps from the AppleScript menu item if you have it installed.

But if you look for a default mode for new windows you'll need to tell Apple because that can't be changed at the moment.

-
If you go to "View:Show View Options" in Finder you'll see what I mean with "All windows", want I want is all folders to be set to the default general setting for icons. So that everyfolder is set to "All windows" and set to icons. All modes, list or column should also be set to "All windows" mode, I rarely even touch the "This window only" button.
Mac Pro 2 x 2.8 GHz Quad-Core, Nvidia GeForce 8800GT
     
JNI
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status: Offline
Reply With Quote
Mar 11, 2004, 12:36 PM
 
Originally posted by Johnny_B:
If you go to "View:Show View Options" in Finder you'll see what I mean with "All windows", want I want is all folders to be set to the default general setting for icons. So that everyfolder is set to "All windows" and set to icons. All modes, list or column should also be set to "All windows" mode, I rarely even touch the "This window only" button.
I don't see any way to set "All Windows" for the view of a folder in AppleScript. I too use that setting for nearly all folders by default. Whenever I open a folder that has custom settings I immediately change it to "All Windows". It usually sticks, but every one in a while the setting seems to get lost and I have to change it again.

I think it is telling that that the AS support for filesystem objects is not fully cooked yet by the fact that setting the current view is currently a property of a Finder Window, and not for say, a folder object. That kind of setting is really part of the meta-data (wherever all that stuff lives...) Setting something like the view, the icon location etc. should really be part of something like the System Events suite, because it should be accessible without the need of the Finder, just like how you can set the name of a file/folder using System Events and not needing the Finder. I.e. the Finder is not required to be running to set attributes of file system objects. I think setting stuff like this should probably be part of the Disk-Folder-File Suite of System Events, possibly a property of a 'disk item' within that context.

It may be currently possible to set something like "All Windows" by using the Scripting UI suite, opening the window of every folder and 'pressing the button" for each folder. But that is obviously a hack.

Maybe if the rumors are true about 10.4 adding more meta-data support to the filesystem, some proper AppleScripting support for this kind of stuff will then be added.
(Last edited by JNI; Mar 11, 2004 at 02:57 PM. )
     
Mac Elite
Join Date: May 2001
Status: Offline
Reply With Quote
Mar 11, 2004, 02:14 PM
 
Originally posted by Johnny_B:
If you go to "View:Show View Options" in Finder you'll see what I mean with "All windows", want I want is all folders to be set to the default general setting for icons. So that everyfolder is set to "All windows" and set to icons. All modes, list or column should also be set to "All windows" mode, I rarely even touch the "This window only" button.
Oh THAT "All Windows" you mean.

Well, like JNI said. I don't see there's a "meta all-windows-window" adressable in AppleScript so the only way would be System Events scripting and that really isn't a comfortable way for this task. You could still use a script like that above to set the view of all windows on a regulary basis.

I am waiting for having more Finder window attributes available in AppleScript (including the column ordering in list view), for the ability to define the default-view of new windows, and for saying goodbye to .DS_Store files.

-
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:03 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2