Mac AppleScript Help

dotoli

macrumors newbie
Original poster
Oct 24, 2007
3
0
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!
 

xUKHCx

Administrator emeritus
Jan 15, 2006
12,587
6
The Kop
Code:
		if name of this_item starts with "Drawn" then
			display dialog "trueee"
                        -- enter move code here
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.
 

MongoTheGeek

macrumors 68040
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!
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.