Modified Batch Convert to Webarchive Script

If anybody needs a new Batch Convert to Webarchives script, I managed to modify the old one to work with 2.0 (pasted below). As per the last thread, there is a new way of handling webarchives in scripts. I think this is working ok but I am not sure about the progress counter so please feel free to test and modify and let me know:

tell application “DEVONthink Pro”
set theSelection to the selection
if theSelection is not {} then
try
activate
show progress indicator “Downloading…” steps (count of theSelection)
repeat with theRecord in theSelection
set theName to name of theRecord
set theURL to URL of theRecord
step progress indicator theName
if exists parent 1 of theRecord then
set theGroup to parent 1 of theRecord
else
set theGroup to missing value
end if
set theData to create web document from theURL in theGroup

			step progress indicator
		end repeat
	end try
	hide progress indicator
end if

end tell

I fixed the counter problem so now the script seems to be working perfectly:

– Convert links to archives

tell application “DEVONthink Pro”
set theSelection to the selection
if theSelection is not {} then
try
activate
show progress indicator “Downloading…” steps (count of theSelection)
repeat with theRecord in theSelection
if type of theRecord is bookmark then
set theName to name of theRecord
set theURL to URL of theRecord
step progress indicator theName
if exists parent 1 of theRecord then
set theGroup to parent 1 of theRecord
else
set theGroup to missing value
end if
set theData to create web document from theURL in theGroup
else
step progress indicator
end if
end repeat
end try
hide progress indicator
end if
end tell

Tip:

Putting scripts in ```

Sorry…I am pretty new to this (scripting) and I was just proud I got the script to work.

If you explain how to do that, next time I will.

Congrats on your script.

Select text and click [Code] in the row of buttons above the text editing field.

Ah so (smacks head)…you mean for pasting into a forum message…I had it in my head that I had formatted something wrong in the script.

So…like this?:


-- Convert links to archives 

tell application "DEVONthink Pro"
	set theSelection to the selection
	if theSelection is not {} then
		try
			activate
			show progress indicator "Downloading..." steps (count of theSelection)
			repeat with theRecord in theSelection
				if type of theRecord is bookmark then
					set theName to name of theRecord
					set theURL to URL of theRecord
					step progress indicator theName
					if exists parent 1 of theRecord then
						set theGroup to parent 1 of theRecord
					else
						set theGroup to missing value
					end if
					set theData to create web document from theURL in theGroup
				else
					step progress indicator
				end if
			end repeat
		end try
		hide progress indicator
	end if
end tell

I should have noticed that it didn’t show up here as nicely formatted as in other messages…sorry.

Yep, like that.