Updating webarchives

That’s funny. I have just written a script the other day that does exactly that.

:warning: Note:

  • It is only necessary to use this script if you captured a part of a website.
  • If you’ve captured via Clip to DEVONthink, i.e. you captured a whole website, then it’s not necessary to use this script.
-- Replace internal webarchive URL with DEVONthink's URL

-- Note: It is only necessary to use this script if you captured a part of a website. If you've captured via Clip to DEVONthink, i.e. you captured a whole website, then it's not necessary to use it.

tell application id "DNtp"
	try
		set theRecords to selected records
		if theRecords = {} then error "Please select a webarchive"
		
		repeat with thisRecord in theRecords
			set thisType to (type of thisRecord) as string
			if thisType is in {"webarchive", "«constant ****wbar»"} then
				set thisURL to URL of thisRecord
				if thisURL ≠ "" then
					do shell script "/usr/libexec/PlistBuddy -c " & quoted form of ("set \":WebMainResource:WebResourceURL\" " & thisURL) & space & quoted form of (path of thisRecord as string)
				end if
			end if
		end repeat
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell