Tote Links identifizieren

Ich speichere in DT viele Internet-Links ab. Ist es möglich, nicht mehr funktionierende Links von DT finden zu lassen?
Frank

Das geht z.B. mit Hilfe von AppleScript, dauert aber je nach Anzahl eine Weile:


tell application id "DNtp"
	set theRecords to the selection
	
	if (count of theRecords) > 0 then
		show progress indicator "Checking Links…" steps (count of theRecords) with cancel button
		try
			repeat with theRecord in theRecords
				set theURL to (URL of theRecord)
				step progress indicator ((name of theRecord) as string)
				if theURL begins with "http" and theURL contains "://" then
					set theStatus to 0
					download URL theURL method "HEAD"
					try
						set theResponse to last downloaded response
						set theStatus to |http-status| of theResponse
						if theStatus ≤ 0 or (theStatus ≥ 400 and theStatus is not 403 and theStatus is not 405 and (theStatus is not 404 or theURL does not contain "github.com/")) then error
						set theDownloadedURL to last downloaded URL
						if theURL is not equal to theDownloadedURL then
							set URL of theRecord to theDownloadedURL
							log message theURL info "Updated URL (" & theDownloadedURL & ")"
						end if
					on error
						log message theURL info "Invalid URL (HTTP " & (theStatus as string) & ")"
						set theGroup to create location "/Invalid URLs" in (database of theRecord)
						replicate record theRecord to theGroup
					end try
				end if
				if cancelled progress then exit repeat
			end repeat
		on error error_message number error_number
			if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
		end try
		hide progress indicator
	end if
end tell

1 Like

Danke. Und wo rufe ich das auf?

In Skript-Editor.app den Code in ein neues Script einfügen, danach das Script entweder direkt im Skripteditor ausführen oder das Script in ~/Library/Application Support/DEVONthink Pro 2/Scripts speichern, so dass es im Scripts-Menü von DEVONthink erreichbar ist.

Guten Abend,
das mit dem Script hat soweit alles funktioniert. Es wird etwas abgearbeitet.

Aber wo sehe ich das entsprechende Ergebnis? :unamused: Wird eine Sammlung erzeugt, in der die Artikel mit den toten Links aufgeführt werden? Vielleicht sehe ich auch nichts, weil ich keine toten Links dabei habe :smiley:

Arbeitet das Script auch nur den Ordner ab, der ausgewählt ist? Es hat für mich den Anschein…

Viele Grüße
Markus

Das Skript verarbeitet nur ausgewählte Dateien.

(Übersetzt mit deepl.com)

Perfekt, jetzt hat es geklappt :slight_smile: Vielen Dank

Gern geschehen!

In Version 3 ist übrigens ein ähnliches Skript für intelligente Regeln enthalten, d.h. eine periodische, z.B. wöchentliche, Regel kann das Skript dann im Hintergrund ausführen. Ist hier bereits seit letztem Jahr so im Einsatz :slight_smile:

1 Like

Die vollständige Regel sieht dann z.B. so aus:

Ah, ok. Das schaue ich mir mal an :+1:t3:

Das bedeutet also, das Script von oben entsprechend abspeichern und in die intelligente Regel einbauen?

Das ist nicht nötig, eine für intelligente Regeln angepasste Version des Skripts ist bereits in DEVONthink 3 enthalten.

Hm, und wo finde ich in der Liste dieses Script. Und wie funktioniert das Ganze dann? Ich habe das Script mal in DEVONthink 2 ausgeführt, finde aber auch nirgendwo das Ergebnis dazu

Intelligente Regeln gibt es ab DEVONthink 3. In DEVONthink Pro (Office) 2.x sollte obiges Skript im Falle von Problemen diese unter Fenster > Protokoll auflisten.