Desktop icon manipulation assistance?

I’d like to create a script that moves icons on the desktop. Well, I wouldn’t like to, I’m getting paid to create an advanced version of this script, but all the ideas and all the components come down to this critical point of actually being able to modify the “x” and “y” positions of the icons of the desktop. This may sound like a rather n00bish thing to ask, but I really just don’t know the command-and when it comes down to programming, you can be programming for 30 years, but if you don’t know the one command, you’re stuck with doing random things like opening the .ds_store files and forcing the program to edit the hex in the file

Did I say that out loud? :stuck_out_tongue:

So, essentially, I just really need help, and I feel bad that this is my first post, but regardless…

Thanks in advance!

-Nic “Lostgame” Newman

Hi Nic,

this sample script moves the icon of the startup disk to x=100, y=200

tell application "Finder"
	set desktop position of disk 1 of desktop to {100, 200} -- (x, y)
end tell

Model: G5 dual 2,5 GHz
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Wow! Thank you so much!

Can you use this with the “every command”?

NULL:And how would you make it relative, meaning, is there a way to return the current x and y of the value “desktop position”?

EDIT: Yeah, it is.

set desktop position of every item of desktop to {deskx, desky}

This is incredible, looking around I really thought it was impossible!

yes, you can also write

tell application "Finder"
	set desktop position of every disk of desktop to {100, 200} -- (x, y)
end tell

but this will result a crush of icons at the same place :wink:

storing the desktop postion into a variable makes it possible to restore the position later

tell application "Finder"
	set pos to desktop position of disk 1 of desktop
	set desktop position of disk 1 of desktop to {100, 200}
	delay 5
	set desktop position of disk 1 of desktop to pos
end tell

Model: G5 dual 2,5 GHz
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Oh, I know that, I’m just saying, it works.

As for the second half:

set itemXY to (desktop position of every item of desktop)

I just made it a list, and the next lines write it to a text file, which I can use from then on.

I just need a way to return the current desktop resolution, just to be proper, to be fair, I could just set their x values to +1,000,000,000 but it’s proper programming to do it the right way, I think. :stuck_out_tongue:

Yah mean somethig like this… :stuck_out_tongue:

http://scriptbuilders.net/files/restoredesktopicons1.5.html

or this…

http://scriptbuilders.net/files/blockoficonsalignampdistribute1.6.html

Or have you got something else in mind?

Regards

Santa

Yes! The latter one is almost exactly what I need, you need to be able to choose the left or the right side of the desktop to put them on though.

Also, I sorta need to write it myself, as I’m getting paid to do it.

G’day Lostgame

Fell free to adapt the script as you like. I don’t believe in copyright for scripts, and a lot of what I wrote is based on bits I’ve found around the place anyway. Just might save you a lot of work.

Good luck with it as a paid effort.

Santa

I did it successfuly, all thanks to you guys and the simplicity of applescript.

Thanks a lot!

And Santa, thanks for your help, but I didn’t use your code. I did learn some useful commands from it though. :slight_smile:

EDIT: another quickie-how do I return the size of the icons on the desktop?