Hi All,
I work for an organization that manages fundraising accounts for many individuals. Currently the maintenance of these accounts is geared towards a Windows only App called Partners. There is a group of Mac users that have developed an alternative App in Filemaker. Our last hurdle is to find a way to import monthly updates into our DB. The hitch is that the windows app uses “|” (that a vertical slash, not a capital i). I am trying to use an applescript to convert those “|” to tabs. I have developed applescript that does it but it relies on Tex-Edit. I’d like to do it using a shell script. Any ideas?
thanks,
Dan
Not long ago, there was a very good thread on a search/replace handler that used AppleScript’s text item delimiters. Easy enough to replace your pipes (|) with tabs. My copy of it looks like this:
to switchText of t from s to r
set text item delimiters to s
set t to t's text items
set text item delimiters to r
tell t to set t to beginning & ({""} & rest)
t
end switchText
to convertText(t)
set d to text item delimiters
repeat with n from 1 to count searchList
set t to switchText of t from my searchList's item n to my replaceList's item n
end repeat
set text item delimiters to d
t
end convertText
----
(* stage 1: import old text *)
set currFile to choose file
set openFile to open for access currFile with write permission
set oldText to read openFile
(* stage 2: convert text *)
set newText to convertText(oldText)
(* stage 3: export new text *)
set eof openFile to 0 (* delete old text *)
write newText to openFile
close access openFile
Thanks for the reply. I tried to edit your suggestion for my purposes but it doesn’t work yet. The script just seems to be adding spaces between each character. My script looks like this:
property searchList : {"|"}
property replaceList : {" "}
to switchText of DTR from | to "\t"
set text item delimiters to |
set DTR to DTR's text items
set text item delimiters to " "
tell DTR to set DTR to beginning & ({""} & rest)
DTR
end switchText
to convertText(DTR)
set d to text item delimiters
repeat with n from 1 to count searchList
set DTR to switchText of DTR from my searchList's item n to my replaceList's item n
end repeat
set text item delimiters to d
DTR
end convertText
----
(* stage 1: import old text *)
set currFile to choose file
set openFile to open for access currFile with write permission
set oldText to read openFile
(* stage 2: convert text *)
set newText to convertText(oldText)
(* stage 3: export new text *)
set eof openFile to 0 (* delete old text *)
write newText to openFile
close access openFile