Is it possible to create script hooks which are run when entering a given folder?

I want to creat a script in `my_dir/` , say
% hook_me.m
display('foo bar baz');
which should be run whenever I change the MATLAB current folder to `my_dir/`.
Is that possible?

1 Comment

Why? What are you actually planning on having this script do? [I'm guessing the "disp" statement is just a placeholder.]
Depending on the answers to those questions there may be an alternate way to achieve you goal (putting your code in a Project, for example.)

Sign in to comment.

 Accepted Answer

You would have to define your own cd.m that used builtin('cd') first and then detected whether you were in one of the target directories and if so ran the hook code.
There is no supported way of adding hooks to changing directories.

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!