Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rate Thread Display Modes
Old 02-17-2013, 01:21 PM   #1
the_salmon_mouss
Prospect
 
Join Date: Feb 2013
Posts: 3
open file that has been added to a folder

Hi guys,

i'm mostly new to scripting, besides a few little "new txt-file"-scripts ... but i wanted to add a function to my system:

i'd like have automatically opened all new (txt-)files that will be added to a certain folder. i thought i'd use launchd and the 'watchpath'-function, but i don't get it, how i exactly to write the script ...

anyone to give me a little tutorial?

thanks
Tim
the_salmon_mouss is offline   Reply With Quote
Old 02-17-2013, 07:44 PM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,938
Google for: applescript folder actions
__________________
hayne.net/macosx.html
hayne is online now   Reply With Quote
Old 02-18-2013, 08:28 AM   #3
the_salmon_mouss
Prospect
 
Join Date: Feb 2013
Posts: 3
thank you, i should have mentioned, that was something i thought first of.
But i wasn't sure how to replace the alert-message part with a correct string to open the newly added files.
I tried this:

Code:
on adding folder items to this_folder after receiving added_items
	try
		tell application "Finder"
			--get the name of the folder
			set the folder_name to the name of this_folder
		end tell
		
		-- find out how many new items have been placed in the folder
		set the item_count to the number of items in the added_items
		--create the alert string
		if the item_count is greater than 1 then
			tell application "Finder"
				activate
				open the added_items
			end tell
		end if
	end try
end adding folder items to
the_salmon_mouss is offline   Reply With Quote
Old 02-18-2013, 10:06 AM   #4
NovaScotian
Hall of Famer
 
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 4,945
I use Hazel to do that, but for setting up launchd, I recommend Lingon 3. Either of those approaches is much more reliable than a Folder Action.
__________________
17" MBP, OS X 10.8.3; 27" iMac, OS X 10.8.3
NovaScotian is offline   Reply With Quote
Old 02-20-2013, 09:59 AM   #5
the_salmon_mouss
Prospect
 
Join Date: Feb 2013
Posts: 3
great, thank you! Hazel did the trick for me!
the_salmon_mouss is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:13 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.