Need help with my first script...

Warning: I’m a few days into learning AppleScript, so bear that in mind…

I’m trying to make an applescript in DevonThink Pro that will do the following:
Take my selected text notes and create a new text document with the same title, but remove the path of the original.

Using Hazel, I’ve copied a lot of notes over from Notational Velocity folder into DevonThink Pro. I’ve deleted them from SimpleNote, so now DevonThink Pro has a missing file error. I just want to create a new note with the existing title so I can start to work on it in DevonThink Pro.

I’ve been tinkering with the following script, but I’m unsure what to do or if I’m even on the correct path…

tell application "DEVONthink Pro"
	set theDatabase to current database
	set theSelection to selection
	set file_name to filename
	get filename of selection
	set resultObject to make new simple ¬
		at atInsertionLoc ¬
		with data withDataAnything ¬
		with properties withPropertiesValue
end tell

I believe I’m doing well until I get to the resultObject part. Using ScriptDebugger, I copied the syntax for “Make” function. I’m not entirely sure this is what I want to do, though.

I’m having trouble figuring out what “resultObject” would be? What would create the new text document?

I think I would just remove InsertionLoc and DataAnything???

and make “with properties file_name”

Any ideas, recommendations, thoughts, critiques, laughing & pointing, help would be nice. Thanks

Also, if there is an easier way to do this, I’m all ears. I was having trouble manually removing the path of the note, so I didn’t really think it would be possible…

However, I’d like to see this script through if possible. I’ll use the easiest and simplest route, but I want to figure out where I’m going wrong right now…

Thanks again.

If I understand correctly, wouldn’t it be simpler to index your Notational Data folder, then use Move Into Database from the contextual menu (control-click the document)? Another method is to select a document in the indexed Notational Data folder, then use command-C to copy and command-N to make a new document in DEVONthink with the same title and content as the copied document?

Not to discourage your scripting effort, but using existing methods might be faster. The above is what I do over here when I want to use a NV/Simplenote document as the source of a new document in DT. You can reverse the procedure too, by putting an RTF into the indexed Notational Data folder, and use Move to External Folder. That puts the note into the NV/Simplenote stream again. Any tags added to your indexed files are also added to NV/Simplenote.

Finally, I index the Notational Data folder in all of my databases, so that I can use Simplenote no matter what the the destination database will be.

You’re right Korm.

Thanks for pointing out your system. It seems much easier than what I was attempting to do…