Quantcast
Channel: DEVONtechnologies Community - Latest posts
Viewing all articles
Browse latest Browse all 17109

How is title sanitzed to a filename?

$
0
0

I’m writing a script (outside of DT) where I need to determine the filename based on a DT title, so I’m trying to figure out what the sanitization logic is.

A while ago I wrote a small AppleScript, but I guess the logic is a bit more complex. @cgrunenberg would you be able to give some pointers how DT sanitizes a record name to a file name?

on sanitize(str)
	-- We also exclude # to prevent from unwanted taggingev
	set replaceChars to {"%", "&", "/", "?", "<", ">", "\\", "*", "|", ":", "*"}
	set stripChars to {"#"}
	set theResult to ""
	repeat with char in str
		if char is in replaceChars then
			set char to "-"
		else if char is in stripChars then
			set char to ""
		end if
		set theResult to theResult & char
	end repeat
	if theResult ends with "." then set theResult to characters 1 thru -2 of theResult as string
	return theResult
end sanitize

Viewing all articles
Browse latest Browse all 17109

Trending Articles