Modify script to also add date?

I am using the script below to append the URL of captured web pages before exporting. Is there a couple of lines I can add to also append the date that the page was saved?

tell application “DEVONthink Pro”
set theWindow to think window 1
copy the selection of theWindow to theSelection
repeat with theRecord in theSelection
set theURL to URL of theRecord
if theURL is not “” then
set the selection of theWindow to {theRecord}
delay 1
tell text of theWindow
make new paragraph with data (theURL & return & return) at beginning
end tell
tell theWindow to save without asking
end if
end repeat
end tell

Sure, there are only minor modifications necessary:


tell application "DEVONthink Pro"
	set theWindow to think window 1
	copy the selection of theWindow to theSelection
	repeat with theRecord in theSelection
		set theDate to (creation date of theRecord) as string
		set theURL to URL of theRecord
		set the selection of theWindow to {theRecord}
		delay 1
		tell text of theWindow
			make new paragraph with data (theDate & return & theURL & return) at beginning
		end tell
		tell theWindow to save without asking
	end repeat
end tell

Thanks for the great support!

I will test it later.

Tested it…works perfectly. Thanks again! :smiley:

Another small favor. Can this be modifed to also append the name of the page? I assume you add a line something like this:

set theName to Name of theRecord

Is that correct? (is there a guide to the scripting language somewhere?)

Also I need the order to be Name, URL, Date so I assume it would go:

set theName to Name of theRecord
set theURL to URL of theRecord
set theDate to (creation date of theRecord) as string
set the selection of theWindow to {theRecord}

The first three statements just copy some properties from the record to variables (and therefore the order doesn’t matter), the last statement selects (and displays) the record.

But to insert a different text you have to modify the “make new paragraph” statement, e.g. replace “(theDate & return & theURL & return)” with “(theName & return & theURL & return & theDate & return)”

I feel dumb. I didn’t bother to read down the script. I will make the modifications and test it later.

thanks

Excellent. Works great. thanks again.

I’ve spent this morning looking for a script that would add the URL of a document to its text, looping through a group of selected documents if necessary. This script from upthread looks like it ought to work, but it’s not. I select a document in a folder, choose the script, and DTPro bumps me up to the root folder without modifying that document.

Am I missing something?
Thanks.
Mark

10.4.10
DT PRo 1.3.3

Did you select a rich or plain text document? This does not support other document types. In addition, you have to use the three-pane or split view.