RE: applescript-users digest, Vol 3 #863 - 17 msgs
RE: applescript-users digest, Vol 3 #863 - 17 msgs
- Subject: RE: applescript-users digest, Vol 3 #863 - 17 msgs
- From: "Kinsella, John R." <email@hidden>
- Date: Tue, 17 Sep 2002 16:18:11 -0500
Can someone PLEASE help me figure out what I'm doing wrong with this folder
action. I want to check files put in this folder and do a find a replace on
text in these files. I think I've got that step figured out, but I cannot
get the script to actually perform any tasks on list of files in this
folder. I know I'm missing something, but can't figure out what it is. I
tried to do this without a folder script, and just choose the folder, but I
still couldn't get the finder nor word to actually open the file (so that I
can copy the text, do my replacing, and then paste it back.)
Here's the script
property dialog_timeout : 30 -- set the amount of time before dialogs
auto-answer.
on adding folder items to this_folder after receiving added_items
tell application "Finder"
--get the name of the folder
set the folder_name to the name of this_folder
end tell
-- find out how many new items have been placed in the folder
set the item_count to the number of items in the added_items
--display dialog "hi"
tell application "Finder"
--go to the desktop
--activate
--open the folder
set the item_list to list folder this_folder without
invisibles
set this_folder to this_folder as string
repeat with i from 1 to number of items in the added_items
set this_item to item i of the item_list
set openItem to this_item as alias
tell application "Microsoft Word"
activate
open openItem
select all
copy
close
end tell
set ourText to {the contents of clipboard}
set findIt to "Text to replace"
set replaceItWith to ".."
searchReplace(ourText, findIt, replaceItWith)
tell application "Microsoft Word"
paste
save
end tell
end repeat
end tell
end adding folder items to
on searchReplace(theText, SearchString, ReplaceString)
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to SearchString
set newText to text items of theText
set AppleScript's text item delimiters to ReplaceString
set newText to newText as text
set AppleScript's text item delimiters to OldDelims
set the contents of clipboard to newText
return newText
end searchReplace
I'm hoping someone can help me track down my problem.
Thanks in advance!
John Kinsella
IRT-CS
University of St. Thomas
-------------
"The surest way to corrupt a youth is to teach him to hold in higher regard
those who think alike rather than those who think differently."
--Nietzsche
_______________________________________________
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.