I need to replace two returns with one return and a tab. Is it possible to make a folder action that could run on a server and change all of the text files that are dumped into that folder?
it is possible
I’m new at scripting and any help would be greatly appreciated!
The deafening silence results because you obviously haven’t searched the forums for this topic.
There’s a lot here so it’s always good to start with a search. Here’s a beginning:
-- assuming that your text is a string variable (with quotes) named myText:
switchText of myText from return & return to return & tab
-- the handler that does the heavy lifting:
on switchText of t from s to r
set d to text item delimiters
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)
set text item delimiters to d
return t
end switchText
This might get you going, rms0723.
It contains no traps - so make sure text files only are dropped on the folder.
It also assumes that the line-breaks of your text files are return characters (ASCII character 13). If that doesn’t work, try changing the first line of the ‘adding folder items to’ handler to:
to switchText of t from s to r
set d to text item delimiters
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)
set text item delimiters to d
t
end switchText
on adding folder items to after receiving fileList
tell return to set {s, r} to {it & it, it & tab}
repeat with currFile in fileList
set openFile to open for access currFile with write permission
set currText to read openFile
set newText to switchText of currText from s to r
set eof openFile to 0
write newText to openFile
close access openFile
end repeat
end adding folder items to
ugg, beat me to it
I waited for 10 hours…
I got home from a perty, started working on theproblem again, then got the email notification that you had posted