AppleScript Help

Discussion in 'Mac Programming' started by dotoli, Oct 31, 2007.

  1. macrumors newbie

    Oct 24, 2007
    Hi there, I am trying to create a folder action so that when i move files to a specific folder each file is sent to another folder depending on their filename.

    on adding folder items to this_folder after receiving these_items
    	display dialog "start"
    	repeat with i from 1 to number of items in these_items
    		set this_item to item i of these_items
    		display dialog "yay"
    		if name of this_item starts with "Drawn" then
    			display dialog "trueee"
                            -- enter move code here
    			display dialog "faaalse"
    		end if
    	end repeat
    	display dialog "end"
    end adding folder items to
    Now for some reason the script halts at the IF check but i can't figure out why!

    Any help would be greatly appreciated!
  2. Administrator emeritus


    Jan 15, 2006
    The Kop
    Instead of that try this

    	set itemname to info for this_item
    	set itemname to name of itemname
    	if itemname starts with "Drawn" then
    		display dialog "trueee"
    Should sort things out.
  3. macrumors 68040


    Sep 13, 2003
    Its not so much where you are as when you are.
    AppleScript itself doesn't know for names.

    tell application "Finder"
    	if name of this_item starts with "a" then move file this_item to folder "Apple" of folder (path to documents folder)
    end tell

Share This Page