I am trying to write something that will detect a new file in a certain specified directory. I preferably would like this script to continue running indefinitely, and whenever I see a new file, I can copy it and move it somewhere else. I know this has to be possible, because dropbox does it, but I just do not know how to get this working or where to start. Any ideas?
Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up
Join them; it only takes a minute:
|
What you're looking for (to spawn off Applescripts when adding new files into a "hot folder") is called "Folder Actions", and there are a number of tutorials that can be found online that should point you in the right direction. For example, here is one: "AppleScript: Exploring the power of Folder Actions, part I" |
|||
|
|
|
Here is another example of a folder action. You should save the script in ~/Library/Scripts/Folder Action Scripts .
Keep in mind that if your script saves anything to the target folder, the folder action will be triggered again. |
|||
|
|