RE:deleting text
RE:deleting text
- Subject: RE:deleting text
- From: email@hidden
- Date: Tue, 25 Nov 2003 16:09:29 -0500
- Priority: normal
Hi Ruby,
This isn't anything spectacular, but see if this works for
you. Make sure to always test on a copy of your original
file just in case it doesn't work correctly since this
script overwrites the contents that were in the file.
I believe this should work okay for your file size, but if
you have huge files you need to read, you'll probably need
to change the code to read in chunks.
Hope this helps.
Jay
---------------
set fText to (choose file)
set fixedText to deleteChars(fText)
try
set fixedFile to (open for access fText with write
permission)
set eof fixedFile to 0
write fixedText to fixedFile
close access fixedFile
on error
close access fixedFile
end try
to deleteChars(f)
set f to read f
set text item delimiters to "\\"
set f to f's text items
set text item delimiters to ""
set f to f as string
set text item delimiters to "|"
set f to f's text items
set text item delimiters to ""
f as string
end deleteChars
---------------
=======
Hi all
I am having problem with a simple
script..........................
I have text files (over 60 to 200 paragraphs). I am trying
to write a script to delete the "\" always in front of a
word and "|" (pipe) at end of a word. "\" and "|" can be at
beginning and end of one word. Sounds simple but I can't get
the delete statement to work. What am I missing here and am
I using the wrong command and or wrong approach. (trying
with the slash first). Can tell I am a beginner at
scripting.
Set NewFile to Pathname
On deleteslash
Set outfile to open access file NewFile with write
permission
Set File1Text to read outfile from 1
Set wordlist to every word of File1Text
Repeat with aword in wordlist
Display dialog aword - to debug
If aword contains "\\" then
Display dialog aword -to debug
Delete character 1 of aword
End if
End repeat
Close access outfile
Return
End deleteslash
Sample text file:
Debugging - this isn't \removing| illegal listening devices
from your office. It's \tracking down and fixing| script
problems.
Thanks in advance
Ruby
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.