How to write a script that runs whenever a new file is added to a specific directory? I've never written a script for OS X, and I don't really know which scripting tool i'll use for this task.

Here's a pseudo code for the script I want to build : 

whenever a new file X is added to the directory D do:
copy X 
paste X to the directory B


I don't want someone to code this for me, I want to know what tool (language maybe) should I use to write this script, and how to make OS X runs it whenever the event occurs.

I don't know what to tag this. Please contribute.
Please redirect if this isn't the right forum for this question.
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.