How to batch removing document's url

Sometimes the PDF documents indexed into the Devonthink databases have lengthy urls, that have little usage but take many lines to display in the “Inspector”.

How to do a batch removing of such urls?

Thanks.

You could e.g. use a script:

tell application id "DNtp"
	set theSelection to the selection
	repeat with theRecord in theSelection
		set URL of theRecord to ""
	end repeat
end tell

A modified version of this script could also be used by smart rules.

1 Like

Thank you! I have added the script into Script Folder and Smart Rules, it works.

Is it possible to apply the script to database/folder/subfolder as well, now I first manually select document items (in a folder) to apply.

This requires a slightly revised script:


tell application id "DNtp"
	set theSelection to the selection
	my removeURLS(theSelection)
end tell

on removeURLS(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set URL of theRecord to ""
			my removeURLS(children of theRecord)
		end repeat
	end tell
end removeURLS
2 Likes

For automation, I’d like to apply the above url-remove script when a database is opened, with a smart rule, “On Open”->“Execute Script”->Embedded, such as the following,

on triggered(theRecord)
    try
	    tell application id "DNtp"
		    set theSelection to the selection
		    repeat with theRecord in theSelection
			    set URL of theRecord to ""
		    end repeat
	    end tell
    end try
end triggered

But my attempt fails, any comments? Thanks.

This is a triggered script which can be attached via the Info inspector to an item. A smart rule script would look like this:

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set URL of theRecord to ""
		end repeat
	end tell
end performSmartRule

But please remember to exclude bookmarks and feeds from your smart rule, otherwise the smart rule will remove their URLs too and make them useless.

Thank you for the explanation, and the reminder.

Appreciated!