AppleScript Help

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

  1. macrumors newbie

    #1
    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.

    Code:
    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
    			
    		else
    			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

    xUKHCx

    #2
    Instead of that try this

    Code:
    	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

    MongoTheGeek

    #3
    AppleScript itself doesn't know for names.

    Code:
    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