I routinely export Extensis Portfolio catalog custom field values into tab delimited text files and sometimes encounter a problem when importing these files back in to a Portfolio catalog. Portfolio exports in tab delimited format so I think the problem is that tabs or new lines have slipped in to the contents of the Portfolio fields I an exporting. If while importing a tab delimited text file Portfolio encounters a tab or new line which is not at the end of a field or record, the data gets garbled. So I am stripping out the offensive characters with the snippet below.
Can I just use “tab” (as below) to strip out tabs or do I need to use “\t”? How would I represent a new line? How could I specify any character without using a literal?
Thanks for any insights.
--set text2 to my replace_chars("this is a test", " ", "-")
tell application "Portfolio"
activate
set workDoc to document 1
set workGallery to a reference to gallery "all items" of workDoc
tell workGallery
repeat with i from 1 to count of records
tell record i
set value of field "Comment" to my replace_chars(value of field "Comment", tab, "")
end tell
end repeat
end tell
end tell
beep 5
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars