Created
November 10, 2010 05:18
-
-
Save howite/670391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
property image_extension_list : {"tif", "tiff", "gif", "png", "pict", "pct", "jpg", "jpeg", "bmp"} | |
property video_extension_list : {"avi", "mov", "mpg", "mpeg", "wmv", "mp4", "m4a"} | |
property audio_extension_list : {"mp3", "wav", "aac"} | |
property archive_extension_list : {"zip", "sit", "tar", "tgz", "gz", "bzip2"} | |
property documents_extension_list : {"doc", "docx", "pdf", "txt", "xls", "xslx", "ppt"} | |
property diskAlignLeft : true | |
property otherAlignLeft : false | |
property margin : {50, 60, 0, 0} -- {left, top, right, bottom} | |
property xPadding : 50 | |
property yPadding : 50 | |
arrangeIcons() | |
to arrangeIcons() | |
set myDisk to {} | |
set myFolder to {} | |
set myImage to {} | |
set myVideo to {} | |
set myAudio to {} | |
set myArhive to {} | |
set myDoc to {} | |
set myOther to {} | |
tell application "Finder" | |
set myDisk to every disk of desktop | |
set myFolder to every folder of window of desktop | |
set myFiles to every file of window of desktop | |
repeat with this_item in myFiles | |
if (the name extension of the this_item is in the image_extension_list) then | |
set the end of myImage to this_item | |
else if (the name extension of the this_item is in the video_extension_list) then | |
set the end of myVideo to this_item | |
else if (the name extension of the this_item is in the audio_extension_list) then | |
set the end of myAudio to this_item | |
else if (the name extension of the this_item is in the archive_extension_list) then | |
set the end of myArhive to this_item | |
else if (the name extension of the this_item is in the documents_extension_list) then | |
set the end of myDoc to this_item | |
else | |
set the end of myOther to this_item | |
end if | |
end repeat | |
set myScreen to bounds of window of desktop | |
end tell | |
set (item 1 of myScreen) to (item 1 of myScreen) + (item 1 of margin) | |
set (item 2 of myScreen) to (item 2 of myScreen) + (item 2 of margin) | |
set (item 3 of myScreen) to (item 3 of myScreen) - (item 3 of margin) | |
set (item 4 of myScreen) to (item 4 of myScreen) - (item 4 of margin) | |
if (diskAlignLeft) then | |
set myScreen to arrangeIconsLeft(myScreen, myDisk) | |
else | |
set myScreen to arrangeIconsRight(myScreen, myDisk) | |
end if | |
if (otherAlignLeft) then | |
set myScreen to arrangeIconsLeft(myScreen, myFolder) | |
set myScreen to arrangeIconsLeft(myScreen, myImage) | |
set myScreen to arrangeIconsLeft(myScreen, myVideo) | |
set myScreen to arrangeIconsLeft(myScreen, myAudio) | |
set myScreen to arrangeIconsLeft(myScreen, myArhive) | |
set myScreen to arrangeIconsLeft(myScreen, myDoc) | |
set myScreen to arrangeIconsLeft(myScreen, myOther) | |
else | |
set myScreen to arrangeIconsRight(myScreen, myFolder) | |
set myScreen to arrangeIconsRight(myScreen, myImage) | |
set myScreen to arrangeIconsRight(myScreen, myVideo) | |
set myScreen to arrangeIconsRight(myScreen, myAudio) | |
set myScreen to arrangeIconsRight(myScreen, myArhive) | |
set myScreen to arrangeIconsRight(myScreen, myDoc) | |
set myScreen to arrangeIconsRight(myScreen, myOther) | |
end if | |
end arrangeIcons | |
to arrangeIconsLeft(myScreen, iconsArray) | |
tell application "Finder" | |
set iconSize to icon size of the icon view options of window of desktop | |
set myX to (item 1 of myScreen) | |
set myY to (item 2 of myScreen) | |
repeat with this_item in iconsArray | |
if (myY + iconSize + yPadding) > (item 4 of myScreen) then | |
set (item 1 of myScreen) to (item 1 of myScreen) + iconSize + xPadding | |
set myX to (item 1 of myScreen) | |
set myY to (item 2 of myScreen) | |
end if | |
set the desktop position of this_item to {myX, myY} | |
set myY to myY + iconSize + yPadding | |
end repeat | |
end tell | |
if not (myY = (item 2 of myScreen)) then | |
set (item 1 of myScreen) to (item 1 of myScreen) + iconSize + xPadding | |
end if | |
return myScreen | |
end arrangeIconsLeft | |
to arrangeIconsRight(myScreen, iconsArray) | |
tell application "Finder" | |
set iconSize to icon size of the icon view options of window of desktop | |
set myX to (item 3 of myScreen) | |
set myY to (item 2 of myScreen) | |
repeat with this_item in iconsArray | |
if (myY + iconSize + yPadding) > (item 4 of myScreen) then | |
set (item 3 of myScreen) to (item 3 of myScreen) - iconSize - xPadding | |
set myX to (item 3 of myScreen) | |
set myY to (item 2 of myScreen) | |
end if | |
set the desktop position of this_item to {myX - iconSize, myY} | |
set myY to myY + iconSize + yPadding | |
end repeat | |
end tell | |
if not (myY = (item 2 of myScreen)) then | |
set (item 3 of myScreen) to (item 3 of myScreen) - iconSize - xPadding | |
end if | |
return myScreen | |
end arrangeIconsRight |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment