PDA

View Full Version : AppleScript Help




dotoli
Oct 31, 2007, 06:58 AM
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

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
Oct 31, 2007, 07:18 AM
if name of this_item starts with "Drawn" then
display dialog "trueee"
-- enter move code here



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.

MongoTheGeek
Oct 31, 2007, 07:21 AM
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

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.


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