accessing the toolbar of a finder window...

ok so i’m trying to write a code to help automate the process of burning disks and i think im doing ok so far. where i’m stuck is trying to use the “click” command on the toolbar… this is the code ive got so far…

display dialog "Do You Want To Burn Something On This Disk?" -- ask to burn
display dialog "Which Folder To Burn" default answer " "
copy text returned of the result to myFolder
tell application "Finder"
	activate
	open folder myFolder of folder "Desktop" of folder "robertbecker" of folder "Users" of startup disk
end tell
tell application "System Events"
	click menu item "Burn	 myFolder to Disk..." of menu item 8 of menu bar 1
end tell
end/applescript]

Model: mac pro
AppleScript: 2.3
Browser: Safari 531.21.10
Operating System: Mac OS X (10.6)


display dialog "Do You Want To Burn Something On This Disk?" -- ask to burn
display dialog "Which Folder To Burn" default answer " "
copy text returned of the result to myFolder
tell application "Finder"
	activate
	open folder myFolder of folder "Desktop" of folder "robertbecker" of folder "Users" of startup disk
end tell
tell application "System Events"
	click menu item "Burn	 myFolder to Disk..." of menu item 8 of menu bar 1
end tell
end


I think the application disk utility can burn folders… and as such there’s a unix command for the disk utility application called diskutil. SoI think using diskutil would be the best way to accomplish your task because gui scripting is often unreliable.

Search the forums for diskutil and I bet you’d find a script like you want.

You certainly mean drutil.
diskutil manages only local disks

so is there no way to reach the finder toolbar using a script then?

Hi,

try this (the script assumes english as system language)


display dialog "Do You Want To Burn Something On This Disk?" -- ask to burn
set myFolder to choose folder "Which Folder To Burn"
tell application "Finder"
	activate
	reveal myFolder
end tell
tell application "System Events"
	tell process "Finder"
		click (get first menu item of menu 1 of menu bar item "File" of menu bar 1 whose name starts with "Burn")
	end tell
end tell

thats almost it exactly im only having one issue with that and its thus, it opens my script folder rather then desktop. ive tried to fix that using two methods but im such a noob i haven’t gotten it quit yet. heres what ive tried so far…


display dialog "Do You Want To Burn Something On This Disk?" -- ask to burn
set myFolder to choose folder "Which Folder To Burn" default location "Desktop" -- i get error message Can't make "Desktop" into type alias. "desktop" 
tell application "Finder"
	activate
	reveal myFolder
end tell
tell application "System Events"
	tell process "Finder"
		click (get first menu item of menu 1 of menu bar item "File" of menu bar 1 whose name starts with "Burn")
	end tell
end tell

I’ve also tried this…


set myDesktop to folder Desktop of folder "robertbecker" of folder "Users" of startup disk
display dialog "Do You Want To Burn Something On This Disk?" -- ask to burn
set myFolder to choose folder "Which Folder To Burn" default location "Desktop"
tell application "Finder"
	activate
	reveal myFolder
end tell
tell application "System Events"
	tell process "Finder"
		click (get first menu item of menu 1 of menu bar item "File" of menu bar 1 whose name starts with "Burn")
	end tell
end tell

the parameter of default location must be an alias


set myFolder to choose folder "Which Folder To Burn" default location (path to desktop)

display dialog "Do You Want To Burn Something On This Disk?" -- ask to burn
set myFolder to choose folder "Which Folder To Burn" default location folder "desktop" of folder "robertbecker" of folder "Users" of startup disk
tell application "Finder"
	activate
	reveal myFolder
end tell
tell application "System Events"
	tell process "Finder"
		click (get first menu item of menu 1 of menu bar item "File" of menu bar 1 whose name starts with "Burn")
	end tell
end tell

i get “Expected end of line, etc. but found “””."


display dialog "Do You Want To Burn Something On This Disk?" -- ask to burn
set myFolder to choose folder "Which Folder To Burn" default location "Desktop:robertbecker:Users:Sai Ram"
tell application "Finder"
	activate
	reveal myFolder
end tell
tell application "System Events"
	tell process "Finder"
		click (get first menu item of menu 1 of menu bar item "File" of menu bar 1 whose name starts with "Burn")
	end tell
end tell

i get error “Can’t make "Desktop:robertbecker:Users:Sai Ram" into type alias.” number -1700 from “Desktop:robertbecker:Users:Sai Ram” to alias

I also tried using POSIX path method but i may have done it wrong , keep in mind im a wicked nood…

and again thanks for all your help

folder "desktop" of folder "robertbecker" of folder "Users" of startup disk

is no alias, its a finder file specifier and works only in a Finder tell block.
You could use this


tell application "Finder" to set myFolder to folder "Desktop" of folder "robertbecker" of folder "Users" of startup disk as alias

but path to desktop is exactly the same

"Desktop:robertbecker:Users:Sai Ram"

doesn’t work, because a literal string is no alias and your startup volume isn’t named “Desktop” (I guess Sai Ram)
you can use

"Sai Ram:Users:robertbecker:Desktop:" as alias

A POSIX path doesn’t work at all

YAY!! so i went with…


tell application "Finder" to set myDesktop to folder "Desktop" of folder "robertbecker" of folder "Users" of startup disk as alias
display dialog "Do You Want To Burn Something On This Disk?" -- ask to burn
set myFolder to choose folder "Which Folder To Burn" default location myDesktop
tell application "Finder"
	activate
	reveal myFolder
end tell
tell application "System Events"
	tell process "Finder"
		click (get first menu item of menu 1 of menu bar item "File" of menu bar 1 whose name starts with "Burn")
	end tell
end tell

and it works fantastic! Stefan you are THE man and if i could give you a cookie i surely would :smiley:

what’s wrong with


set myFolder to choose folder "Which Folder To Burn" default location (path to desktop)

?
It’s the easiest and most portable solution. path to desktop is always the alias to the desktop of the current user regardless of the name of the startup volume and the name of the user

oh i see i thought (path to desktop) was were i was s’posed to enter in MY path, i didnt realize it was an alias :smiley: