Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

brianus

macrumors 6502
Original poster
Jun 17, 2005
401
0
Hi, is there a way to select a filename for editing in the Finder using AppleScript? I have a Folder Action which checks for proper filenames (according to company criteria) in a particular folder. It's fine for dragging items into the folder, but if you create a new folder in there and start to edit the name, the Folder Action causes it to interrupt your editing. I've already changed the script so that it takes no action when the filename starts with "untitled folder", but it STILL causes the edit box to go away regardless. So I'm figuring the only way to deal with this is to somehow make the Finder re-select the filename for editing at the end of the script, but I haven't found a way to do this. The "select" action only highlights the file, it doesn't open the edit box.
 

MongoTheGeek

macrumors 68040
Hi, is there a way to select a filename for editing in the Finder using AppleScript? I have a Folder Action which checks for proper filenames (according to company criteria) in a particular folder. It's fine for dragging items into the folder, but if you create a new folder in there and start to edit the name, the Folder Action causes it to interrupt your editing. I've already changed the script so that it takes no action when the filename starts with "untitled folder", but it STILL causes the edit box to go away regardless. So I'm figuring the only way to deal with this is to somehow make the Finder re-select the filename for editing at the end of the script, but I haven't found a way to do this. The "select" action only highlights the file, it doesn't open the edit box.

You could try having system events type a return.

Perhaps the best thing is to throw up a dialog asking what you want the folder named.

Code:
tell application "Finder"
	set aname to name of folder blahblahblah --substitute whatever var you are getting in
	if aname = "untitled folder" then
		set aname to text returned of (display dialog "What do you want this folder named?" default answer "untitled folder")
		set name of folder blahblahblah to aname
	end if
end tell
checkname(blahblahblah)
 

brianus

macrumors 6502
Original poster
Jun 17, 2005
401
0
You could try having system events type a return.

Perhaps the best thing is to throw up a dialog asking what you want the folder named.
[/CODE]

I might wind up doing that if there's no other way, though I'd like to avoid interrupting the normal workflow as much as possible (lots of people use this folder). I'm new to AppleScript so I'm not quite clear on how SystemEvents works.. I tried:

Code:
tell application "System Events" to key code 10

to enter a return but nothing happened.

I wonder if there's some way to get the folder action to run without removing focus from the Finder window. It's odd that it would even have to do that, since there's no other window involved.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.