Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 556223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:53:50+00:00 2026-05-13T11:53:50+00:00

In Snow Leopard, I want to trigger a script/code whenever a user duplicates a

  • 0

In Snow Leopard, I want to trigger a script/code whenever a user duplicates a directory in Finder. How can I do that?

I’ve been hunting around the docs, but I’m a little too new this type of work to recognize the right approach.

Motivation: If a directory is under version control, say with git or hg or svn, and the user duplicates that dir, then I want to run a script that searches for the original dir and then makes a ‘tag’ in version control. If the user renames the dir, say within 10 seconds, then the rename would be part of that tag comment. I’d eventually like to throw on some overlay icons to indicate the version control state of the dir, too.

Expanded Motivation: The problem that I face is that that version control software, like git, and hg, in my opinion is too complicated namely because it is too disconnected from the file system and acts as sort of a shadow-filesystem. I’m a big fan of version control and have used it for many years – but I have also seen the limits of deployment because of its complexity. The reality is that a lot more code would be under version control if it were easier to use.

I’m investigating the feasibility of creating an easier to use VCS system that doesn’t require terminal access. Imagine what version control (for code) would look like if Apple were to make it part of finder and/or iLife – simple, but good-enough. In reality, I’m obviously not going to re-invent a vcs, but I’m hoping that building a module/plugin for something like hg, and coupling that with a re-envisioning of how vcs works for a finder-centric UI a – all to create a simpler, but good enough, VCS for the more casual programmer.

The first technical hurdle detecting directory copies and renames – and hence this question.

Number of Files: Since the primary motivation of this project is for source code version control, I only need to match the number of directories matching the number of projects you are working on. So, if you are working on two distinct projects, then, I think, that I only need to track two directories – the root of each project. Now, I fully admit that I may, at this point be mis-characterizing the need, so maybe I need to track all of the directories in the projects, or maybe even all of files in those projects, too, so lets say, for the sake of argument, that a typically project has 1,000 files in it. So, basically, maybe only a few directories, or a few hundred directories, or maybe a few thousand files. Importantly, I think 50,000 files would be at the higher end of the spectrum.

User duplicates the dir ‘trunk’ from within finder

trunk –> trunk copy

If the user renames ‘trunk copy’ to ‘trunk copy fixed #255 per colors’
the trunk dir (not the copy) would be tagged with
the comment ‘fixed #255 per colors’

References:

  • File System Event Programming

    • Get notified, upon start-up, if something in a registered dir changed – if any one file in a large dir changes. It won’t tell you, I don’t think, what got changed.
  • Kernel Queues

    • You can register to be notified of things at the individual file level. You’re options are (at least) the following:
      NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_LINK | NOTE_RENAME | NOTE_REVOKE This could maybe be used to detect a directory rename (will it work for dirs?), but apparently not a dir copy.

Slightly related question:

  • How to write finder plugin

Thanks,
JJ

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:53:50+00:00Added an answer on May 13, 2026 at 11:53 am

    The original post suggested a really large project, with a lot of unspecified features. Your ‘expanded motivation’ ending with ‘… detecting directory copies and renames …’ was helpful.

    First, you pretty much answered your own post with the references to File System Events and Kernel Queues. You were correct to dismiss Folder Actions, but for the wrong reason. You seemed concerned with activating FAs for a large number of folders. That is not a problem, because it could be automated. The reason FAs won’t work is that they can’t detect a file rename. Also, there is a huge problem with overhead and concurrency because the actions are AppleScript.

    And you were correct about FS Events: (from Darwin Docs)

    The important point to take away is
    that the granularity of notifications
    is at a directory level. It tells you
    only that something in the directory
    has changed, but does not tell you
    what changed.

    So it seems you are left with Kernel Queues. They do everything. Note that you will have to be clever to use Kernel Queues- you have to know the name of a flie to monitor it. So as new files/folders are created, you will have to interpret the events, and open (O_EVTONLY) the new files. However, there is a problem: (more Darwin Docs)

    If you are monitoring a large
    hierarchy of content, you should use
    file system events instead, however,
    because kernel queues are somewhat
    more complex than kernel events, and
    can be more resource intensive because
    of the additional user-kernel
    communication involved.

    Another reply had mentioned that TimeMachine used FS Events. I doubt that because of the noted ‘coarse granularity’. I suspect that there is a special hook in the kernel ‘close file’ code. At least, that is what it seems you need if you want to monitor many files. How many are you considering?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 351k
  • Answers 351k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You may be interested in TextHelper's truncate function: truncate("Once upon… May 14, 2026 at 7:13 am
  • Editorial Team
    Editorial Team added an answer This is more of a C than a C++ question… May 14, 2026 at 7:13 am
  • Editorial Team
    Editorial Team added an answer The link sends only the loginName parameter. You have to… May 14, 2026 at 7:13 am

Related Questions

I must be missing something simple, but I can't see it. First, the setup:
hay guys, i'm having all sorts of mod_rewirte trouble in snow leopard. Anyone know
In Xcode (3.2 on Snow Leopard) when I start to type out a function
I'm trying to decide which path to take for developing my Snow Leopard app.
I want to ship a single 32/64-bit universal binary of my desktop Mac OS

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.