Adam, this is great! Thanks for the help. So let me see if I get this. (I hope I’m not being to annoying
)
–
Here you are setting up the variables.
property tWatchFiles : missing value – properties “keep” from run to run
property tProjects : missing value
when the program runs it’s directed to a specific folder and is told to think of the folder as “checkFiles(WatchedFolder)”. I’m not sure why you would want to change its identity though. If you know the name of the folder, why change it?
on run – this runs when the application is started
set WatchedFolder to (choose folder) as alias
checkFiles(WatchedFolder)
end run
maybe my previous thought was wrong. This statement looks like “checkFiles” is a function. As the program idles it constantly checks the “Watchedfolder”. So now I’m a bit confused about the “as alias” bit. I’ll try to look that up.
on idle – idle scripts are saved as stay-open AppleScript applications and cycle periodically.
checkFiles(WatchedFolder)
end idle
the function “checkFiles”
to checkFiles(wF) -Don’t know what the (wF) is for
set pFiles to {} -Don’t know what this line is for
this makes sence. get the contents of the “WatchFolder” and make a list of it to use later.
tell application “Finder”
set tProjects to folders of WatchedFolder as alias list
If you have made the list why would you need the repeat? And why the “aFolder”? Are we trying to make a list of the contents of any folder nested within each project folder?
repeat with aFolder in tProjects
set pf to files in aFolder as alias list
Is the repeat going one more level deeper?
repeat with af in pf
Here is where my head starts to spin a bit. I understand that it is told to look for files with the “_RCF.txt” in the name. But I’m not sure where this pFiles come from and what it does. did we just create another variable, “pFiles”?
if name of af contains “_RCF.txt” then set end of pFiles to contents of af
end repeat
end repeat
end tell
OK. Head spinning more. We are reading the RCF text files here. We open it up and look for something with “(Finished” in it. Then it starts getting confusing. What is “astid” and this “AppleScript’s text item delimiters”?
repeat with RCF in pFiles
set thisList to read RCF
set astid to AppleScript’s text item delimiters
I think not knowing what the “AppleScript’s text item delimiters” does is confusing me here. Not sure where “TI” and “tList” comes from.
set text item delimiters to “(Finished”
Very confused here.
set TI to text items of tList
set text item delimiters to “”
set Fin to first word of last paragraph of first item of TI → “item2”
Once you have funished checking the text files execute the funtion “DoStuff”.
– but as set up only gets the first one. This is just to illustrate how you get one.
my DoStuff(Fin)
end repeat
end checkFiles
to DoStuff(someRef)
– press on with stuff
end DoStuff
–
So in my “DoStuff” function, after I have it move the finished project to a new folder, I’ll have it email the designer. I found the following script that seasm to work well.
–
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set |to| to "scott@flyingspot.com"
set |from| to "scott@flyingspot.com"
set smtpServer to "smtp server here"
--> delete the three following lines if you don't need authentication:
set username to "scott@flyingspot.com"
set |password| to "password here"
set authentication to auto --> or plain, login, crammd5, anonymous
set theSubject to "Applescript test"
set thebody to "This is a test! This is only a test"
--> Now, compose the source and send the email...
set rawSource to "Date: " & (do shell script "date '+%a, %e %b %Y %H:%M:%S %z'") & return & ¬
"To: <" & |to| & ">" & return & ¬
"From: <" & |from| & ">" & return & ¬
"Subject: " & theSubject & return & ¬
"Mime-Version: 1.0
X-Mailer: XMail
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: quoted-printable" & return & ¬
thebody
try
send raw mail to |to| from |from| raw source rawSource SMTP server smtpServer username |username| password |password| authentication |authentication|
on error number -2753 --> you don't need authentication and such variables are undefined...
send raw mail to |to| from |from| raw source rawSource SMTP server smtpServer
end try
set AppleScript's text item delimiters to oldTID
–
Looks like pieces are starting to fall into place. Wow a sence of accomplishment. Thanks for the help!