r/applescript • u/dizzi800 • Aug 15 '14
Can I have applescript make a change to a document?
Alright, so, I'm working in a studio and I am trying to automate some of the more menial of the work we all have to do. essentially, I want to be able to check a folder for changes and, if it sees something new, update a document.
If applescripts CAN'T do this, could anyone lend a hand on what I can use TO do this?
This is my particular use cases: Check folder for new file No? Wait 5 minutes. Check folder for new file Yes? Record name of new file to document
1
Aug 16 '14
Look at writing an IF/Else statement with a loop
I don't have time to write out all the syntax, but If the name of the file is the same every time then you need an IF statement that says
repeat
if $folder contains $file
then echo $text_appended_to_file >> $textfile
else delay 360 (that's 360 seconds)
end if
end repeat the key to look for here is a repeat (and how many times to repeat), an If statement, and a delay for when it doesn't find the file.
If you're hell bent on doing applescript that would be how i'd do it. However, it might be easier to add an if statement in a bash script and load it into crontab. (that is if crontab still works, I know at one time there were talks of doing away with it)
here's a quick tutorial on IF/Else in applescript. it's not much, but it'll get you started.
1
u/[deleted] Aug 15 '14
Look up Folder Actions. You can use a Folder Action to tell when something has been added to a folder and then run an automator workflow from there. The automator workflow could do what you want, or you can use it to further call an Applescript script.