How to import CSV of URLS as Web Archives (with Tags)?

My assumption is that importing various sorts of content via CSV with a method like this is a very common use case

That’s almost always a dangerous thing to do. :stuck_out_tongue:


This is a simple example using a two column sheet…

tell application id "DNtp"
	repeat with thisRecord in (selection as list)
		if (type of thisRecord) = sheet then
			set sheetData to (cells of content record of think window 1)
			repeat with thisData in sheetData
				try
					set newRecord to create web document from (item 1 of thisData) in current group
					set tags of newRecord to (item 2 of thisData)
				end try
			end repeat
		end if
	end repeat
end tell

Note the title is picked up by the process. If you want to use the title in the sheet, that’s certainly possible.

Also note commas are tag delimiters in macOS’ token fields now. This code is actually taking advantage of that to create separate tags without having to parse the tag column.

PS: This is not doing any URL validation, etc. It’s expecting valid URLs.

1 Like