AppleScript to Attach a file via alias instead of embedded?

James Spahr james at spahr.org
Fri May 19 09:31:47 PDT 2006


This is the script I use. It isn't exactly what you want, but this is  
what it does:

When run from OO3 (place the script in ~/Application Support/ 
OmniOutliner 3/Scripts/) it will take the current selection and place  
it as a child to the current row in OO. If the finder selection is a  
folder, it will re-create the file system's hierarchy in OO

When compiled an run as a droplet, you can drag and drop files on it  
and those files will be placed in the front most OO document.


---

on open of theFiles
	
	repeat with f in theFiles
		process_item(f as alias)
	end repeat
	
end open


on run
	
	tell application "Finder"
		set the_files to selection
	end tell
	
	repeat with f in the_files
		process_item(f)
	end repeat
	
end run

on process_item(f)
	
	tell application "Finder"
		set is_folder to (class of f is folder)
		set is_file to (class of f is document file)
	end tell
	
	if is_folder then
		set f_array to every item of f
		repeat with ff in f_array
			process_item(ff)
		end repeat
	else if is_file then
		tell application "Finder"
			set u to the URL of f
		end tell
		add_file_as_child(u)
	end if
	
end process_item

on add_file_as_child(u)
	
	tell application "OmniOutliner Professional"
		try
			set the_current_row to selected row 1 of document 1
			set new_row to make new row at the end of (children of  
the_current_row)
		on error
			set new_row to make new row at the end of (rows of document 1)
		end try
		set topic of new_row to u
	end tell
	
end add_file_as_child

---




On 19 May 2006, at 11:25 AM, George Crump wrote:

> I am still very new to applescripting so if you (our anyone else)  
> could find your script and wouldn't mind sharing that would be a  
> huge help.
>
> On May 18, 2006, at 11:22 PM, James Spahr wrote:
>
>>
>> yes, I've done this. (written a script (somewhere on my HD at this  
>> point) to catalog folders in OO)
>>
>> All you do is set the text of a give outline node to "file:///path/ 
>> to/file" and OO auto hot links it to a file instead of embedding it.
>>
>> On 19 May 2006, at 12:09 AM, George Crump wrote:
>>
>>> Looking for some help. I am trying to see if a script exists that  
>>> would change/replace the attach button with a Link button/script  
>>> that would always set up an alias to a file as opposed to  
>>> embedding the file. I know you can do this by ctrl dragging a  
>>> file but some time its easier to do via a open file dialog box.  
>>> Has anyone seen this or can someone give provide some sample code?
>>>
>>> Thanks in Advance,
>>>
>>> George
>>>
>>> _______________________________________________
>>> OmniOutliner-Users mailing list
>>> OmniOutliner-Users at omnigroup.com
>>> http://www.omnigroup.com/mailman/listinfo/omnioutliner-users
>>
>>
>>     James Spahr
>>     james at spahr.org
>>
>>
>>
>
> _______________________________________________
> OmniOutliner-Users mailing list
> OmniOutliner-Users at omnigroup.com
> http://www.omnigroup.com/mailman/listinfo/omnioutliner-users


     James Spahr
     james at spahr.org





More information about the OmniOutliner-Users mailing list