"on adding folder items" Folder Action interrupts editing of new folder names

Discussion in 'Mac Programming' started by brianus, Aug 30, 2007.

  1. brianus macrumors 6502

    Jun 17, 2005
    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.
  2. MongoTheGeek macrumors 68040


    Sep 13, 2003
    Its not so much where you are as when you are.
    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.

    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
  3. brianus thread starter macrumors 6502

    Jun 17, 2005
    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:

    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.

Share This Page