Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm building a packaged-based OS X image, and, with new software added, the Application's folder is a mess (with icons obscuring each other and things in disarray).

I thought deleting the .DS_Store file would fix it, but it doesn't seem to. Is there a command I could run (preferably when not logged in graphically as any user) to mimic the effect of choosing "View -> Keep Arranged By -> Name" in a Finder window in an arbitrary directory?

share|improve this question
    
Is there any particular reason to vote to close this question? Possibly is could be asked on Super User, but a normal user wouldn't care about fixing the icon layout on a disk image to be deployed to hundreds of users. –  Clinton Blackmore Jan 18 '10 at 16:07
add comment

2 Answers

...or you could go to the Dark Side and use AppleScript.

tell application "Finder"
    set w to make Finder window to folder "MyApp" of folder "Applications" of startup disk
    set p to icon view options of w
    set the current view of w to icon view
    set the icon size of p to 32
    set the label position of p to bottom
    set the arrangement of p to arranged by name
    close w
end tell

...which you can run from the command-line via osascript.

(Based on this example)

share|improve this answer
    
I do believe that this is the answer. I'll have to try it out and see if it works for me. –  Clinton Blackmore Jan 18 '10 at 16:04
    
Hmmm... It looks like it requires the Finder to be running. I do hope to have something that can run when no one is logged in. –  Clinton Blackmore Jan 18 '10 at 16:06
add comment

A given folder's Finder sort attributes appear to actually be stored in its parent folder's .DS_Store. So if you're interested in modifying sorting of the contents of /Applications/MyApp/, you'll need to adjust the contents of /Applications/.DS_Store.

For example, if I diff hexdumps of /Applications/.DS_Store after changing the sorting of /Applications/MyApp from 'name' to 'none', I get this:

@@ -42,8 +42,8 @@
 00000600  00 00 00 23 40 59 00 00  00 00 00 00 23 40 28 00  |...#@Y......#@(.|
 00000610  00 00 00 00 00 23 3f f0  00 00 00 00 00 00 10 00  |.....#?.........|
 00000620  23 3f f0 00 00 00 00 00  00 23 00 00 00 00 00 00  |#?.......#......|
-00000630  00 00 23 00 00 00 00 00  00 00 00 08 09 54 6e 61  |..#..........Tna|
-00000640  6d 65 09 23 40 48 00 00  00 00 00 00 00 08 00 25  |me.#@H.........%|
+00000630  00 00 23 00 00 00 00 00  00 00 00 08 09 54 6e 6f  |..#..........Tno|
+00000640  6e 65 09 23 40 48 00 00  00 00 00 00 00 08 00 25  |ne.#@H.........%|
 00000650  00 3b 00 47 00 50 00 65  00 74 00 8b 00 97 00 a3  |.;.G.P.e.t......|
 00000660  00 b0 00 c5 00 d3 00 dd  00 ef 00 f8 01 01 01 0a  |................|
 00000670  01 13 01 1c 01 1e 01 27  01 30 01 39 01 3a 01 3b  |.......'.0.9.:.;|

Unfortunately there doesn't seem to be any good documentation on the .DS_Store file format, nor do there seem to be any command-line utilities for modifying it.

share|improve this answer
    
Thanks for the research. Good heavens, I wouldn't have expected that! –  Clinton Blackmore Jan 18 '10 at 16:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.