How to write a script that runs whenever a new file is added to a specific directory?
Very simple using Automator &amp; Folder Actions.


Make a new Folder Action, then set the source to Folder A  
select a Finder action from the left column,  
drag 'Copy Finder Items' from the centre to the right  
set the destination to Folder B.
Give it a name &amp; save.




Every time anything is added to A it will automatically copy to B.